Extjs网格过滤器 - Dynamic ListFilter [英] Extjs Grid Filter - Dynamic ListFilter

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

问题描述

我正在使用覆盖的数据存储(而不是硬编码的列表)来实现Ext.ux.grid.filter.ListFilter 这里是ExtJS 4 API 。数据不错,我在这一列上看到一个过滤器选项,但它只是说加载...,过滤器选项应该是:

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:

我很确定我有根据API规范配置,但没有运气。有没有人正确地实现了?

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
}

我有一些想法:

我需要我的过滤器选项数据存储具有特定的列标题,如名称而不是水平?

Do I need my filter option data store to have a specific column title, like "name" instead of "level"?

这是试图在从ajax加载之前获取商店选项,并且有一些未指定的方法来告诉它在

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)

编辑:

json响应看起来像这样,不知道是否造成麻烦:

The json response looks something like this, not sure if it is causing the trouble:

[{"levels":"Level 1"},{"levels":"Level 2"},{"levels":"Level 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):

{
    header: 'Level',
    dataIndex: 'levels',
    itemId: 'levels',
    width: 160,
    sortable: true,
    filter: {
        type: 'list',
        options: [],
        phpMode: true,
    }
}

商店:

var levelStore = Ext.create('Ext.data.Store', {
    fields: ['levels'],
    proxy: {
        type: 'ajax', 
        url: '../json?queryName=levels',
        reader: 'json'
    },
    autoLoad: {
        callback: function() {
            grid.getView().getHeaderCt().child('#levels').initialConfig.filter.options = levelStore.collect('levels');
        }
    }
});

('grid'是我用筛选器命名我的网格的变量)

('grid' is the variable that I named my grid with the filters)

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

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