Does an associated store support filter and filterBy?
I filter it to show only products whose name starts with 'F':
or the product named 'Foo':
None of them works.
They work only if:
This way it works, but I duplicated the store.
Am I missing something in the docs?
Thanks in advance
Does associated store supports filtering?
I'm dealing with a MainStore whose records have an associated store Products; I bind a list to Products of 1st record:
Code:
MyList.setStore(Ext.getStore('mainStore').getAt(0).Products())
I filter it to show only products whose name starts with 'F':
Code:
MyList.getStore().filterBy(function(item,id) {
return item.get("name").charAt(0).toUpperCase() === 'F';}
or the product named 'Foo':
Code:
MyList.getStore().filter('name', 'Foo');
None of them works.
They work only if:
- The store is a normal "simple store", eg. loaded from a JSON - not nested or at the root "nesting level"
- The store is created and filled at runtime, eg.:
Code:
var Products = Ext.create('Ext.data.Store', { storeId: 'productsStore', model: 'Myapp.model.Product'});
//... later in the controller
init: function() {
Ext.getStore('mainStore').on('load', function() {
this.getAt(0).Products().each(function(item, idx) {
Products.add(item.copy());
}
});}
This way it works, but I duplicated the store.
Am I missing something in the docs?
Thanks in advance
Question within the question:
Using .add(item) instead .add(item.copy()) does add a reference to the item, thus avoiding duplication?
It works anyway
Does associated store supports filtering?
Aucun commentaire:
Enregistrer un commentaire