PDA

View Full Version : EXTJS arraystore - filterby



rajuarien
27 Nov 2013, 10:50 AM
var store = new Ext.data.ArrayStore({
fields: ['id', 'name'],
data: [
[1, 'Lucas'],
[2, 'Pablo'],
[3, 'Francisco']
]
});


var eventList = store.filterBy(function (rec, id) {
return (rec.get("name") == "Lucas" || rec.get("name") == "Pablo");
});
eventList is always undefimed :-?
console.log("No of Records : " + eventList.getCount());

dumontbass
27 Nov 2013, 12:24 PM
Try it:


var combo = Ext.ComponentQuery.query('#itemId') // itemId: config on field
var store = combo[0].getStore() // first matched component
store.filterBy(function (rec, id) {
/*return ( !rec.data.get('processavel') || !rec.data.get('fracionavel') ) => DOESN'T WORKS */
var isProcessavel = rec.get('processavel');
var isFracionavel = rec.get('fracionavel');

console.log(isProcessavel)
console.log(isFracionavel)

return ( isFracionavel || isProcessavel);

});


Works fine here.

The filter by doesn't return anything, it just passing a function trough the inner scope , as can see on AbstractStore.js

filterBy: function(fn, scope) {


},