PDA

View Full Version : Looping a store



PDOOMS
13 Jan 2011, 7:58 AM
I want to loop a store via a 'for' statement, check some field values and do a specific action based on the values.
The store is loaded via an url. I thought this is easy but I do not succeed. The store is loaded but I can't get the values.

Thanks

darthwes
13 Jan 2011, 8:01 AM
Ext.data.Store.each(fn, [scope])
See the docs for Ext.data.Store (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Store).

PDOOMS
19 Jan 2011, 11:57 PM
Following code works fine but how can I access the values outside this onload event ?

colStore.on('load', function(store, records, options) {
colStore.each(function(record) {
console.log(record.get('colname'));
},this);
});

darthwes
20 Jan 2011, 8:33 AM
Wrap it in a closure. TY.


function createClosure(a, b, c) {
return function(store, records, options) {
//use a, b, c, store, records, options
};
}(this, myWindow, someOtherObjectC);