从 ExtJS 中的存储中删除过滤器

发布于 2024-12-03 01:52:40 字数 230 浏览 0 评论 0原文

我使用 store.filter(string, string) 方法显式向 Ext.data.Store 添加过滤器。

但是,我不知道如何从商店中删除过滤器。因此,即使在使用 store.load() 重新加载后,过滤器也始终适用。我看到的唯一解决方法是重新启动整个网络应用程序。

如何从 Ext.data.Store 中删除过滤器?

I explicitly add a filter to a Ext.data.Store using the store.filter(string, string) method.

However, I can not figure out how to remove filters from the store. So the filters always apply even after reloading using store.load(). The only workaround I see is to restart the entire web app.

How do I remove a filter from an Ext.data.Store?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌生 2024-12-10 01:52:40

除了 Mchi 的回答之外,我想说的是,可以删除特定的过滤器(clearFilter() 将它们全部删除)。
为此,不要使用 store.filter('property_to_filter','value') 方法,而是使用:

store.filters.add('filtersId', new Ext.util.Filter({
  property: 'property_to_filter',
  value: 'value'
}));
store.load();

删除过滤器 使用:

store.filters.removeAtKey('filtersId');

Update (for > 4.2.0)

在 4.2.0 方法中添加/删除特定过滤器已添加:

store.addFilter({
    id: 'filtersId',
    property: 'property_to_filter',
    value: 'value'
});

store.removeFilter('filtersId');

有关更多信息,请查看文档:Ext.data.Store.addFilter, Ext.data.Store。删除过滤器

In addition to Mchi's answer, I want to say that it is possible to remove specific filter (clearFilter() removes them all).
To do that, instead of using store.filter('property_to_filter','value') method, use:

store.filters.add('filtersId', new Ext.util.Filter({
  property: 'property_to_filter',
  value: 'value'
}));
store.load();

to remove filter use:

store.filters.removeAtKey('filtersId');

Update (for > 4.2.0)

In 4.2.0 methods for adding/removing specific filter were added:

store.addFilter({
    id: 'filtersId',
    property: 'property_to_filter',
    value: 'value'
});

store.removeFilter('filtersId');

For more info check out docs: Ext.data.Store.addFilter, Ext.data.Store.removeFilter

通知家属抬走 2024-12-10 01:52:40

编辑:我刚刚发现(浏览 API 以了解其他内容)它甚至更容易。有一个参数(布尔值),如果为 true,则在使用 RemoteFilter 时不会重新加载数据...

所以这里是:

store.clearFilter(true);
store.filter(...);

来源:存储 API >清除过滤器

我不敢相信我为此挣扎了这么久。在我查看的每个论坛中,我都看到clearFilter,它对于远程过滤没有用,我所要做的就是添加“true”...

原始帖子:

“您需要clearFilter()

IMO,这绝对不能令人满意。
当使用服务器后端获取数据时(很多人都会这样做),使用remoteSortremoteFilter+分页来管理大型结果集,它甚至毫无用处。

调用 clearFilter() 实际上会在重新应用过滤器之前重新加载数据。因此每次应用过滤器时都会发送 2 个 ajax 请求。这件事困扰了妈妈很久。

实际上你所要做的就是:

store.filters.clear(); // Which is what clearFilter() does just before reloading the data...
store.filter(...);

Edit: I just found out (browsing the API for something else) that it's even easier. There's a parameter (boolean) which, if true, doesn't reload the data when using remoteFilter...

So here goes :

store.clearFilter(true);
store.filter(...);

Source: Store API > clearFilter

I can't believe I struggled for so long with that. In every forum I looked, I saw clearFilter which wasn't useful for remote filtering, and all I had to do was to add "true"...

Original Post:

"You need to clearFilter()"

IMO, this is absolutely not satisfying.
When using a server backend to get the data (as many would), with remoteSort and remoteFilter + paging to manage large result sets, it's even useless.

Calling clearFilter() actually reloads the data before reapplying the filter. So 2 ajax requests are sent each time a filter is applied. This has bothered ma for a long time.

All you have to do is actually :

store.filters.clear(); // Which is what clearFilter() does just before reloading the data...
store.filter(...);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文