Extjs6 Excel像带有商店的网格过滤器 [英] Extjs6 Excel like grid filters with store

查看:111
本文介绍了Extjs6 Excel像带有商店的网格过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为网格创建一个复杂的过滤器.我想要以下一般行为:

I am trying to create a complex filter for a grid. I want the following general behavior:

  • 过滤器与网格的存储不同
  • 在A列上应用过滤器
  • 根据我的选择过滤网格
  • B列中的过滤器将显示可用项目

此外,网格还具有一个按钮,可清除所有过滤器,并清除所有内容,从过滤器中删除选中的项目.

Also, the grid has a button that clears all the filters and more, remove the checked items from the filters.

基于此链接试图做类似的事情.我还创建了一个小提琴.

Based on this link I've tried to do something similar. I've created also a fiddle.

关于小提琴,我有一个问题:

Regarding the fiddle, I have some question:

1.以下代码返回 undefined .根据文档,它应该返回一个Menu对象.

1.The following code returns undefined. Based on the documentation it should return a Menu object.

business.filter.menu = business.filter.createMenu({
        store: localStore
})

2.我想在用户按下清除在线过滤器按钮时清除选中的项目.

2.I want to clear the checked items when user press the Clear Inline Filter button.

    var f = Ext.ComponentQuery.query('test-grid')[0].getColumnManager().getHeaderByDataIndex(element).filter;
    if (f.menu) {
        for (var j = 0; j < f.menu.items.length; j++) {
            f.menu.items.items[j].setChecked(false)
        }
    }

在这里,f.menu始终是未定义的,因此我无法清除该复选框.我莫名其妙地失去了对菜单的引用.

Here the, f.menu is always undefined so I can't clear the checkbox. Somehow I lose reference to menu.

如何根据我的情况清除复选框?为什么 createMenu 返回未定义?

How to clear the checkboxes based on my scenario? Why the createMenu returns undefined?

修改

接受的答案适用于该特定问题(小提琴)

The accepted answer worked for this specific question(fiddle)

推荐答案

一般说明: 不要调用在文档中明确标记为私有的方法/使用属性. 这通常意味着您做某事的方式是错误的,还有另一种更自动化的方式来实现. 特别是不要以Ext4示例为例,而是将它们1:1移植到Ext5或Ext6. 该框架在Ext5中进行了很多更改,在Ext6中进行了一些更改.

On a general note: Don't call methods/use properties explicitly marked private in the documentation. This usually means the way you're doing something is wrong and there is another more automated way to achieve that. Especially don't take Ext4 examples and port them 1:1 to Ext5 or Ext6. The Framework changed quite a lot in Ext5 and a little more in Ext6.

在这种情况下,应该从过滤器存储库自动创建过滤器菜单,而无需人工干预. 为了取消选中菜单项,只需停止按该值进行过滤即可.

In this case the filter menu is supposed to be created automatically from the filter store without human interaction. In order to uncheck a menu items, simply stop filtering by that value.

使用ColumnManager查找特定列也是内部使用的保留,但是我可以看到为什么要这样做.比手动过滤响应表单getColumns容易.

Using the ColumnManager to find a certain column is also a reserved for internal use, but I can see why you'd want to go that way. It's easier than filtering the response form getColumns by hand.

这篇关于Extjs6 Excel像带有商店的网格过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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