如何在ExtJS中应用过滤器 [英] How do I apply filter in ExtJS

查看:143
本文介绍了如何在ExtJS中应用过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用:

Ext.ux.grid.FiltersFeature

它工作正常,但每当我加载我的商店数据

It works fine, but whenever I load my store data

tablePanel.store.loadData(..)

过滤器不受尊重。这些列被视觉选择为过滤(即,灰色),但是显示所有行而不是已过滤的行子集。

the filters are not respected. The columns are visually selected as filtered (ie. greyed out), but all the rows are shown instead of the filtered subset of rows.

这是一个被捕获的错误JSFiddle:

Here is the bug trapped in a JSFiddle :

http://jsfiddle.net / oliverwatkins / 7hbt79bj / 4 /

重现我的问题:


  • 在名称上选择列过滤器,值为'foo'

  • 现在只显示一行(foo行)

  • 现在点击

  • 过滤器设置为仅显示foo,但也显示bar。

  • Select column filter on Name, to the value 'foo'
  • Now only one row should show (the foo row)
  • Now click on Reset.
  • The filter is set to only show 'foo', but it shows 'bar' as well.

我知道有一种方法可以删除过滤器:

I know there is a method which removes filters :

grid.store.clearFilter();

我正在寻找一种这样的方法:

I am looking for a method like this :

grid.store.applyFilters();

所以我可以在刷新表中的数据后执行。

So I can execute it after I refresh the data in my table.

**更新**

如果我深入挖掘一下,我可以在表格面板中看到是一个过滤器字符串设置。

If I dig a bit deeper I can see that in the table panel there is a filter string being set.

tablePanel - > filters - > filters - > items - > [1] - > inputItem - > value ='mySearchString'

然而,这是tablePanel上的过滤器。如果我看到tablePanel - > store,我会发现没有设置项目的过滤器:

However that is the filters on the tablePanel. If I look at the tablePanel-->store instead, I find filters with no items set :

tablePanel - > store - > filters - >过滤器 - >项目 - > [0]

几乎就好像有两种不同的过滤系统在这里玩不与每个其他。

It is almost as if there are two different filtering systems at play here which are not communicating with each other.

什么让事情更令人激动的是,该商店有一个过滤器方法,网格没有一个过滤器方法。 / p>

And what makes things all even more infuriating is that store has a filter method, and grid does not have a filter method.

grid.store.filter(); //method exists

grid.filter(); //crashes

puzzling ..

puzzling..

推荐答案

我使用了你的小提琴,并提出了一套解决方案存储负载后的值。在 grid.store.loadData 之后,我添加了一个逐个重新应用过滤器的代码。

I used your fiddle and came up with a solution that sets the values after store load. After grid.store.loadData I added this code that reapplies the filters one by one.

var filterData = grid.filters.getFilterData();
Ext.Array.each(filterData, function(filter){
    grid.filters.filters.getByKey(filter.field).setValue(filter.data.value)
})

这篇关于如何在ExtJS中应用过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆