Extjs 网格过滤器 - 动态列表过滤器
我正在尝试使用数据存储(而不是硬编码列表)来实现 Ext.ux.grid.filter.ListFilter 在 ExtJS 4 API 中。数据很好,我在该列上看到一个过滤器选项,但它只是说“正在加载...”,其中过滤器选项应该是:
我很确定我已按照 API 规范进行了配置,但对此没有任何运气。有人正确实施过吗?
我用来获取过滤器选项的存储是这样设置的:
// get the levels for filtering
var levelStore = Ext.create('Ext.data.Store', {
fields: ['levels'],
proxy: {
type: 'ajax',
url: '../json?queryName=levels',
reader: 'json'
},
autoLoad: true
});
我在列中实现了过滤器配置,如下所示:
{
header: 'Level',
dataIndex: 'levels',
width: 160,
sortable: true,
filter: {
type: 'list',
store: levelStore
}
我的一些想法:
我是否需要我的过滤器选项数据存储具有特定的列标题,例如“名称”而不是“水平”?
这是试图在从ajax加载存储选项之前获取它们,并且有一些未指定的方式告诉它在ajax返回之后加载这些过滤器选项?
我是否需要将过滤器配置与列配置分开才能使用此配置? (我的所有其他过滤器配置都在列配置中完成,并且似乎工作正常)
编辑:
json 响应看起来像这样,不确定它是否引起了麻烦:
[{"levels":"Level 1"},{"levels":"Level 2"},{"levels":"Level 3"}]
I am trying to implement Ext.ux.grid.filter.ListFilter using a data store (rather than a hardcoded list) as covered here in the ExtJS 4 API. The data comes in fine and I see a filter option on this column but it just says "Loading..." where the filter options are supposed to be:
I am pretty sure I have this configured as per the API specs but have not had any luck with this. Has anyone implemented this correctly?
The store I use to get the filter options is set up like this:
// get the levels for filtering
var levelStore = Ext.create('Ext.data.Store', {
fields: ['levels'],
proxy: {
type: 'ajax',
url: '../json?queryName=levels',
reader: 'json'
},
autoLoad: true
});
I implemented the filter config in the column like so:
{
header: 'Level',
dataIndex: 'levels',
width: 160,
sortable: true,
filter: {
type: 'list',
store: levelStore
}
Some thoughts I had:
Do I need my filter option data store to have a specific column title, like "name" instead of "level"?
Is this trying to get the store options before they are loaded from ajax, and there is some unspecified way of telling it to load these filter options after the ajax is returned?
Do I need to implement my filter configuration separate from the column config to use this one? (all my other filter configurations, are done right in the column config and seem to work fine)
EDIT:
The json response looks something like this, not sure if it is causing the trouble:
[{"levels":"Level 1"},{"levels":"Level 2"},{"levels":"Level 3"}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我现在已经解决了。我最终使用空选项数组
options: []
配置过滤器,然后在存储上放置一个回调,将过滤器选项添加到空选项数组中。像这样:列模型(带有过滤器配置):
商店:(
“网格”是我用过滤器命名网格的变量)
I have it resolved now. I ended up configuring the filter with an empty options array
options: []
and then put a callback on the store that adds the filter options to the empty options array. Like this:The column model (with filter config):
The store:
('grid' is the variable that I named my grid with the filters)
我在使用 ExtJs 4.0.2a 时也有同样的情况。我
已经找到了
autoLoad对于存储必须为 false 的内容以及
Ext.ux.grid.menu.ListMenu` 的一些补丁。商店:
并将 ext-4.0.2a/examples/ux/grid/menu/ListMenu.js 中的 show 方法替换为:
I have the same when using
ExtJs 4.0.2a
. Ive find what
autoLoadmust false for store and some patch to
Ext.ux.grid.menu.ListMenu`.The store:
And replace show method in
ext-4.0.2a/examples/ux/grid/menu/ListMenu.js
with:这很简单
This is simple