View Full Version : Delayed Filter

24 Nov 2011, 4:22 AM

I have a problem with store filtering:
I have Ext.view.View( shows only one item from the store at the one monent),
The idea is to show store-item, then if user wants to see another item, I'll load it to store, and filter the store, and when user returns back to prev-record it will should be fetched from store.

in my controller I try to do this

//store.getCount() === 0 ???? why???
if(!store.findRecord('itemId', myItemId)) {
addRecords: true,
params: {
itemId: myItemId

store.filter('itemId', myItemId);

my store has an option filterOnLoad: true;

24 Nov 2011, 8:40 AM
I have moved this to the Ext JS 4.x Q&A forum for you, you're welcome. Please post in the correct forum.

25 Nov 2011, 2:10 AM
I do not understand your problem. Plz explain. But filtering a store can also be done like below.

store.filterBy(function(r) {

var val = r.get('itemId');

if(val == 'yourcomparison'){
return true;

return false;


25 Nov 2011, 3:20 PM
Ok, let's see an example.

In the application there is a widget that shows full company's information (director, description, avatar and other options). Also in application there is list of companies (Ext.panel.Grid), when user clicks on item in Grid, he should see full company's information.

To solve this, I decided to do the followings:
I've create two stores, Companies for Grid and CompanyDetais for my widget (Ext.view.View)
When user clicks on company from Grid I perform clearFilter for my CompanyDetais-store to reset all my previous filters and perform simple check

if(CompanyDetais.findRecord('companyId', selected_company_id) {
CompanyDetais.filter('companyId', selected_company_id);

If record doesn't exists in CompanyDetails I make an Ajax request to load it.

else {
addRecords: true,
params: {
companyId: selected_company_id

CompanyDetais.filter('companyId', selected_company_id);

In CompanyDetais-store property filterOnLoad: true, so it should work, but
before: CompanyDetais.clearFilter(), CompanyDetais.getCount() > 0
after: CompanyDetais.clearFilter(), CompanyDetais.getCount() === 0