View Full Version : filter store without duplication to an other store

15 Oct 2012, 1:30 PM
Hi,I ama a begginer in extjs developpement and i have a problem to filter a store
I have a store containing data which can find duplicates like this example:
var store = Ext.create('Ext.data.JsonStore', {
fields: ['id','name' ],
data: [
{'id':2,'name':'name2' },
I want to apply a filter to extract this data store to another store (array. ..) the value of field 'name' and the number of occurrences of each value of the field:
As this example:
var store1 = Ext.create('Ext.data.Store', {
fields:['value', 'occurence'],
{'name1', 2},
{'name2', 2},
{'name3', 1}
] });
I try to use find() and filter() but i failed to have a store that perofrms the search.
I need your help

17 Oct 2012, 6:49 AM
store.filter('name', 'name1');
var count = store.getCount();

Should give you how many records are in the store after the filter.

1 Nov 2012, 2:05 AM
thank for your help, but i dont like pass a value in the filter parameters,
just, i must dynamically filter duplicate values of a store and return the unique items names and their number of occurences

1 Nov 2012, 4:50 AM
The store's collect method can tell you the deduplicated value list but it won't tell you counts.

To get counts you could maybe use each to iterate over the store and count up how many of each value you see.

1 Nov 2012, 9:50 AM
thank, i used the collect method and i solved the problem