开发者

Applying a filter to an `Ext.data.Store` while adding to said store

开发者 https://www.devze.com 2023-04-01 01:45 出处:网络
I have some JavaScript which presents my user with a list of items. They can choose to filter the items (there are lot to see) and at the same time, server pushes are adding new items.

I have some JavaScript which presents my user with a list of items. They can choose to filter the items (there are lot to see) and at the same time, server pushes are adding new items.

When the user chooses a filter, I'm applying a filter to an Ext.data.Store like so:

myStore.filterBy(function(record) {
    return (record.data.type === filter);
});

When the server pushes a new it开发者_开发技巧ems to display, I'm using addSorted to add it:

myStore.addSorted(new Ext.data.Record.create(fields)(item));

... but when the user chooses a filter, new items sent by the server aren't getting filtered out.

How can I set up an Ext.data.Store filter such that calls to addSorted and add will respect the filter being applied to the store?


I'm afraid the only solution is to re-apply the filterBy function after adding the new record.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号