PDA

View Full Version : Ext.data.Store filterBy with Ext.Panel displaying all data



binaryfever
12 Feb 2010, 8:15 PM
Hi,

Been awhile since I posted on the forums. Just ran into an issue that I can't seem to solve. I am attempting to filter a Store with filterBy and all the data is getting displayed. I am wondering if it has to do with my extra data readers.



//Create the assetFormat reader
var assetFormatReader = new Ext.data.XmlReader({
record:'assetFormat',
fields: [
{name:'url', mapping:'url'},
{name:'type', mapping:'type'}
]
});

//Create the tag reader
var tagReader = new Ext.data.XmlReader({
record:'tag',
fields: [
{name:'id', mapping:'@id'},
{name:'name', mapping:'@name'}
]
});

//Create the data store
var ds = new Ext.data.Store({

proxy: new Ext.data.HttpProxy({
url: 'assetTagResponse.xml'
}),

reader: new Ext.data.XmlReader({
record: 'asset',
id: '@id',

fields: [
{name: 'id', mapping: '@id'},
{name: 'title', mapping: 'title'},
{name: 'shortabstract', mapping: 'shortabstract'},
{name: 'assetFormats', convert:function(v,n){
return assetFormatReader.readRecords(n).records;
}
},
{name: 'tags', convert:function(v,n){
return tagReader.readRecords(n).records;
}
}
]
})
});

ds.load();
ds.filterBy(function myFilter(record){
return false;
});

var resultTpl = compileTemplate();

var panel = new Ext.Panel({
applyTo: "search_panel",
title: "test panel",
height:768,
autoScroll:true,

items: new Ext.DataView({
tpl: resultTpl,
store: ds,
itemSelector: 'div.search-item'
})
});


I was under the impression I should load the store, filter it, then render the display. Is this not correct? am I missing something completely.

Thanks for any help or pointers.

tobiu
12 Feb 2010, 11:50 PM
ds.load();
ds.filterBy(function myFilter(record){
return false;
});



won't do. you calll the filter before the store is loaded.

ds.on('load' : function(){...});

should help. ajax-responses won't arrive in realtime.
kind regards,
tobiu