Hi there,

I'm having some issues with a simple GroupingStore and a DynamicJsonReader.
If I have a regular Store no problem, the code works, but when I adjust the code for grouping, I get a:
this.fields.get(c) is undefined
Here's the code:

Code:
Ext.onReady(function(){
    var datefield = new Ext.FormPanel({
        frame: true
        //more code
        defaultType: 'datefield',
        items: [{
            fieldLabel: 'Select a Date',
            name: 'sel_date',
            id: 'sel_date',            
            editable: false,
            listeners: {select: doSend}
        }]
    },
        {
            success: true,
            errors: {
                clientCode: "Client not found",
                portOfLoading: "This field must not be null"
            }
        }
    );
var myDate;
var grid;    
function doSend(){
    //set the date for request
    myDate = datefield.findById('sel_date').getValue().format("m-d-Y");
    if(typeof grid  != "undefined"){
        grid.destroy(true);
    }
    //the attempted groupingstore
    var ds = new Ext.data.GroupingStore({
        proxy: new Ext.data.HttpProxy({url: 'subjectTrack01_.jsp?sel_date='+myDate}),
        reader: new Ext.data.DynamicJsonReader({root: 'rows'}),
        sortInfo:{field: 'Subject Id', direction: "ASC"},
        groupField:'Centre',
        remoteSort: true
    });
    //function to call when loading
    ds.on('load', function(){
        // Reset the Store's recordType
        ds.recordType = ds.reader.recordType;
        ds.fields = ds.recordType.prototype.fields;
        // Create the grid
        grid = new Ext.grid.GridPanel({
           ds: ds,
           cm: new Ext.grid.DynamicColumnModel(ds),
           stripeRows: true,
           frame: true,
           height:500,
           title: 'List of Subjects expected to come at the selected date',
           autoScroll: true,
           view: new Ext.grid.GroupingView({
                forceFit:true,
                groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
            }),
           renderTo: 'date_div'
        });
 
    });
    ds.load();
}
Ext.data.DynamicJsonReader = function(config){
    Ext.data.DynamicJsonReader.superclass.constructor.call(this, config, []);
};
Ext.extend(Ext.data.DynamicJsonReader, Ext.data.JsonReader, {
    getRecordType : function(data) {
        var i = 0, arr = [];
        for (var name in data[0]) { arr[i++] = name; } // is there a built-in to do this?
        this.recordType = Ext.data.Record.create(arr);
        return this.recordType;
        },
    readRecords : function(o){ // this is just the same as base class, with call to getRecordType injected
        this.jsonData = o;
        var s = this.meta;
     var sid = s.id;
     var totalRecords = 0;
     if(s.totalProperty){
            var v = parseInt(eval("o." + s.totalProperty), 10);
            if(!isNaN(v)){
                totalRecords = v;
            }
        }
     var root = s.root ? eval("o." + s.root) : o;
     var recordType = this.getRecordType(root);
     var fields = recordType.prototype.fields;
        var records = [];
        for(var i = 0; i < root.length; i++){
                var n = root[i];
            var values = {};
            var id = (n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
            for(var j = 0, jlen = fields.length; j < jlen; j++){
                var f = fields.items[j];
                var map = f.mapping || f.name;
                var v = n[map] !== undefined ? n[map] : f.defaultValue;
                v = f.convert(v);
                values[f.name] = v;
            }
            var record = new recordType(values, id);
            record.json = n;
            records[records.length] = record;
        }
        return {
            records : records,
            totalRecords : totalRecords || records.length
        };
    }
});
function changeBg(val){
    //code here
}
 
Ext.grid.DynamicColumnModel = function(store){
    var cols = [];
    var recordType = store.recordType;
    var fields = recordType.prototype.fields;
    for (var i = 0; i < fields.keys.length; i++)
    {
        var fieldName = fields.keys[i];
        var field = recordType.getField(fieldName);
        //console.log("["+field.name+"]");
        cols[i] = {header: field.name, dataIndex: field.name, width:150, renderer: changeBg};
    }
    Ext.grid.DynamicColumnModel.superclass.constructor.call(this, cols);
};
Ext.extend(Ext.grid.DynamicColumnModel, Ext.grid.ColumnModel, {});
 
});