PDA

View Full Version : Ext.data.Store.remove() ?



jdhuang
28 Jun 2007, 11:27 PM
var RecordDef = Ext.data.Record.create([
{name: 'name', mapping: 1},
{name: 'occupation', mapping: 2}
]);
var gridData=[['name1','3'],['name2','4']];
var mydataStore = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(gridData),
reader: new Ext.data.ArrayReader({},RecordDef)
});
mydataStore.load();
var newRecord=new RecordDef({name:'name3',occupation:'5'});
mydataStore.insert(0,newRecord);
newRecord.set("name","name4");
//remove the record from mydataStore
mydataStore.remove(newRecord);
var modifiedRecords=mydataStore.getModifiedRecords();
for(var i=0;i<modifiedRecords.length;i++)
{
var rec=modifiedRecords[i];
//result: name4 why?
alert(rec.get("name"));
}

Can anyone help me?

Animal
28 Jun 2007, 11:40 PM
What with?

Anyway, array subscripts start from zero, so mapping:2 isn't going to get anything useful.

And mapping:1 for the name is going to get "name4" from your new record.

jdhuang
1 Jul 2007, 5:01 PM
Thanks Animal.
//remove the record from mydataStore
mydataStore.remove(newRecord);
I think the newRecord has removed from mydataStore
next:var modifiedRecords=mydataStore.getModifiedRecords();
Can not get newRecord。