开发者

extjs-adding a record to a store does not reflect on the grid

hi i have grid with store and i add record dynamically to the store for most times the data being added to the store gets reflected on the grid but sometimes the record dont seem to get reflected on the grid..please help me solve this problem

var entityGrid = new Ext.grid.EditorGridPanel({

    ddGroup           : 'gridDDGroup',
    layout            : 'fit',
    store             : gridStore,
    closable          : true,
    enableDragDrop    : true,
    enableColumnMove  : false,
    enableColumnResize: true,
    columnLines       : true,
    stripeRows        : true,
    colModel          : new Ext.grid.ColumnModel({
        columns:cols
    }),
    expandable        : true,
    autoExpandColumn  : 'name',
    tbar              : gridToolBar,
    view              : new Ext.grid.GridView({  
        enableRowBody : true,
        ignoreAdd     : true,       
        deferEmptyText: false,
        emptyText     : 'No Record found.',       
        getRowClass   : function(record, rowIndex, rp, ds){}
    }), 
    id                : id,
    selModel          : new Ext.grid.RowSelectionModel({
        singleSelect  : tr开发者_开发百科ue
    })

var store =new Ext.data.JsonStore({
    fields : [
        {
            name : 'name',
            mapping : 'name'
        }, {
            name : 'displayName',
            mapping : 'displayName'
        }
    ],
    root : masterData.
})


I am not sure it makes a difference but this code always worked for me:

var r = new store.recordType({ field1: '1', field2: '2' }); 
r.commit();
store.add(r);
store.commitChanges();
grid.store.sort('field1', 'ASC');

Try adding commitChanges() and refreshing.


I'm not sure if you're still plagued by this problem, but I found the code at: http://www.sencha.com/forum/showthread.php?141982-commitChanges-and-rejectChanges-for-the-Store-in-ExtJS-4

to be very useful as things changed moving to EXTJS-4. Which version of EXTJS are you using? Since you're using an EditorGridPanel, I'm guessing it's ExtJS 3. If you'd like, I can contribute a code fragment that uses the above architecture successfully to update a record on a grid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜