PDA

View Full Version : Missing record index after inserting to store



Oliver Specht
14 Nov 2012, 7:03 AM
Hi,
I have a grid and want to insert a new record via context menu.

The insertion works fine but the record indexes get messed up. The index of the newly entered record is undefined and the other indexes remain unchanged.

Do I miss something?

Here's my code:


var addAction = Ext.create('Ext.Action', {
text: 'Add row',
handler: function(widget, event) {
var rec = grid.getSelectionModel().getSelection()[0];
if (rec) {
grid.store.insert(rec.index + 1, new grid.store.model());
grid.getPlugin('rowediting').startEdit(rec.index + 1, 0);
}
}
});



BTW: The documentation is not correct for http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.plugin.Editing-method-startEdit because record and columnHeader can be a Number too.

Thank you,
Oliver

vietits
14 Nov 2012, 7:11 PM
You should not rely on the existing of record index property. It is used internally by the framework and it is not updated when you insert new records to store.