我有一个 ExtJS (4.0) 网格,它工作正常。现在我希望通过添加过滤器来进一步推进它。我希望用户能够按状态过滤项目。
我创建了以下商店:
var status_store = Ext.create('Ext.data.Store', {
model: 'Statuses',
proxy: {
type: 'ajax',
url: '/json/statuses/',
reader: 'json'
}
});
我可以看到它加载,/json/statuses/将返回以下 json 对象:
[
{
"name": "OK",
"isActive": true
},
{
"name": "Outdated",
"isActive": true
},
{
"name": "New",
"isActive": true
}
]
现在我定义过滤器:
var filters = {
ftype: 'filters',
encode: encode,
local: local,
filters: [{
type: 'list',
dataIndex: 'name',
store: 'status_store',
labelField: 'name'
}]
};
并将过滤器添加到我的列定义中:
{text: 'Status', width: 120, dataIndex: 'status', sortable: true, filterable: true, filter: {type: 'list'}},
当网格加载时,我收到以下错误:
Uncaught TypeError: Object json has no method 'read' (ext-all-debug.js:25702)
当我单击菜单的列标题时:
Uncaught TypeError: Object status_store has no method 'on' (ListMenu.js:69)
我该如何解决这个问题,或者我在概念上做错了什么?
以下是我的代码的完整引用,以防万一:http://pastebin.com/SNn6gFJz
最佳答案
感谢您诊断问题。 4.1修复是修改ListMenu.js
在构造函数的 else 部分
替换
me.store.on('load', me.onLoad, me);
与
// add a listener to the store object
var storeObject = Ext.StoreMgr.lookup(me.store);
storeObject.on('load', me.onLoad, me);
me.store = storeObject;
关于javascript - ExtJS网格过滤器: how can I load 'list' filter options from external json?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6004386/