Ext JS CriteriaBuilder

A few weeks ago, I had a scenario come up where I wanted to be able to filter an based on a set of criteria, part of which depended upon a value in one of my model’s associations. While this is easy enough to do via filterBy(), it can become a bit unwieldy to use, especially if you want/need the criteria to be dynamically constructed.

As I was thinking about how to best deal with this, I remembered my experiences of using ColdBox’s CriteriaBuilder, which is based on Hibernate’s API of the same name. Using CriteriaBuilder, you can–among myriad other things–produce complex queries and, because it is all DSL-based, criteria can be added in as dynamic a way as you’d like.

This inspired me to experiment with building a CriteriaBuilder for Ext JS.


CriteriaBuilder allows you to build complex, dynamic queries that can query any data within an, including association data. Since I was bored, I created two approaches for interfacing with CriteriaBuilder.

In the first approach, you can use a SQL-like syntax to craft your query. For example:

var cb = new CriteriaBuilder.Builder({
    store: mystore
var sql = 'join user u where u.lastName like "McD%" order by orderNumber ASC';
// run More >

Sencha Fiddle Documentation

Yes, yes, I know. It’s been over a month now since I’ve posted anything. Life is life, and all that.

Anyway, exciting stuff–the good people over at Sencha put up some documentation for Fiddle today! If you’ve ever wanted to really dig into the features that Fiddle has to offer, be sure to check out the docs.

That’s all for now–happy fiddling!

Share this: