PDA

View Full Version : Difficulty removing records from store



brontd
5 Dec 2011, 2:21 PM
I have a store from which I need to remove certain records before I display the data. The store is loaded, and I can iterate over the set, but I am having trouble calling remove() on the appropriate records. If I read the set into a variable, I can make the necessary deletions, but the iteration is really slow.


var s = this.getStore('myStore');
s.each(function(record) {
s.remove(record);
changed = true;

});

... and if I chain the methods, I can't seem to access the record.


this.getStore('myStore').each(function(record) {
this.remove(record);
});

Am I missing something simple or am I going about this the wrong way? Thanks for your help.

mitchellsimoens
5 Dec 2011, 2:27 PM
Is the store loaded?

tobiu
5 Dec 2011, 3:37 PM
well, there are 2 options:

1) put all records you want to remove into an array and call store.remove() once with that array. this way all the view listeners (dom sizing etc.) will only get fired once.

2) for me it looks like you actually want to filter the store. so take a look at:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-filterBy

brontd
6 Dec 2011, 5:39 AM
Tobias,

I think you are right. The filterBy() method is much faster than each(). Do you know why that is?

In any case, thanks for your help. :D