PDA

View Full Version : ArrayStore troubles



realjax
19 Nov 2009, 6:09 AM
Question: Assume the following code


var myStore = new Ext.data.ArrayStore({
idIndex: 0,
fields: [
'load',
{name: 'status', type: 'string'}
]
});


Wouldn't 'load' be the id field then?
that is, if I add a record like so:



var aRecord = new myStore.recordType({load:'findMe',status:'someText'});
myStore.add(aRecord)


I should be able to find it again right? using:


myStore.getById('findMe')


But, of course, it doesn't. Extjs assigns it's own ID's to each record..
I'm probably missing something obvious but can't see where it is going haywire at the moment.

Animal
19 Nov 2009, 6:43 AM
You did not pass the ID to the constructor. Second param: http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Record&member=Record

realjax
19 Nov 2009, 7:09 AM
Of course!

Thanks for that Animal.