Wow! It's been too long. I've been so buried playing with new stuff I haven't had much time to write about it. Time to rectify that.

My position over the last year and a half hasn't required me to use Ext JS. And without a project I really haven't had much time to dive in to Ext JS 4. But, I am reviewing Loiane's Ext JS 4 First Look right now, and decided the simplest way to get in was to apply what she was telling me. I knew some of the basics, but Ext JS 4 is a big change, and Loaine's book quickly helped me to grok differences in the class model, updates to the data api, and more. In no time at all I had completely rewritten CFQueryReader, for parsing the native JSON return of a ColdFusion query object. I need to verify, but I'm fairly certain there are more lines of comments than there are code, in the new file. And it is wicked simple. First, include the js file, then define a record of data:

view plain print about
1Ext.define('Artist', {
2        extend: 'Ext.data.Model',
3        fields: [
4            {name:'city', type:'string'},
5            {name:'state', type:'string'},
6            {name:'postalcode', type:'string'},
7            {name:'email', type:'string'},
8            {name:'phone', type:'string'},
9            {name:'fax',type:'string'},
10            {name:'thepassword',type:'string'},
11            {name:'artistId', type:'int'},
12            {name:'firstName', type:'string'},
13            {name:'lastName', type:'string'},
14            {name:'address', type:'string'}
15        ],
16        idProperty: 'artistId'
17    });

Then, define your data 'Store':

view plain print about
1Ext.create('Ext.data.Store', {
2        model: 'Artist',
3        storeId: 'artistStore_1',
4        remoteSort: true,
5        proxy: {
6            type: 'ajax',
7            url: '/com/cc/ArtGallery/Artists.cfc',
8            extraParams: {
9                method: 'GetAllStandard',
10                returnFormat: 'json'
11            },
12            reader: {
13                type: 'cfquery'
14            }
15        },
16        autoLoad: true
17    });

That example is for a method that only returns a query. I like to return a struct, so I also included the ability to reference that:

view plain print about
1Ext.create('Ext.data.Store', {
2        model: 'Artist',
3        storeId: 'artistStore_3',
4        remoteSort: true,
5        proxy: {
6            type: 'ajax',
7            url: '/com/cc/ArtGallery/Artists.cfc',
8            extraParams: {
9                method: 'getAllInStruct',
10                returnFormat: 'json'
11            },
12            reader: {
13                type: 'cfquery',
14                query: 'getArtists',
15                totalProperty: 'totalRowCount',
16                successProperty: 'success',
17                messageProperty: 'message'
18            }
19        },
20        autoLoad: true
21    });

It's really that simple! Go pull CFQueryReader from RIAForge and test it out against the demo CFArtGallery datasource included in your CF install.