ExtJS过滤器功能错误
我是ExtJS的新手,我试图在ExtJS网格中包含过滤器,但我遇到了一个错误,比如加载文件“feature.filters”失败。下面是我创建网格的函数,我从另一个HTML页面调用这个函数ExtJS过滤器功能错误,extjs,filter,Extjs,Filter,我是ExtJS的新手,我试图在ExtJS网格中包含过滤器,但我遇到了一个错误,比如加载文件“feature.filters”失败。下面是我创建网格的函数,我从另一个HTML页面调用这个函数 function ExtJSGrid(tableId,headerInfo,data){ Ext.Loader.setConfig({enabled: true}); Ext.Loader.setPath('Ext.ux', 'http://vmxplambardi:19086/teamworks/scri
function ExtJSGrid(tableId,headerInfo,data){
Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', 'http://vmxplambardi:19086/teamworks/script/extjs/examples/ux');
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.ux.grid.FiltersFeature',
'Ext.toolbar.Paging'
]);
var tableId=tableId+"-div";
var fields=[],columns=[],dataIndex='cell';
var filters = {
ftype: 'filters',
local:true,
filters: [{
type: 'string',
dataIndex: 'cell1'
}, {
type: 'string',
dataIndex: 'cell2'
}, {
type: 'string',
dataIndex: 'cell3'
}]
};
document.getElementById(tableId).innerHTML='';
for(var i=1;i<=headerInfo.length;i++)
{
var cellObj={},columnObj={};
cellObj.name=dataIndex+i;
fields.push(cellObj);
columnObj.text=headerInfo[i-1];
columnObj.dataIndex=dataIndex+i;
columns.push(columnObj);
}
var store = Ext.create('Ext.data.ArrayStore', {
fields:fields,
data: data
});
var grid = Ext.create('Ext.grid.Panel', {
store: store,
columns:columns,
width:'100%',
forceFit:true,
features: [filters],
renderTo: tableId
});
}
函数ExtJSGrid(tableId、headerInfo、data){
setConfig({enabled:true});
Ext.Loader.setPath('Ext.ux','http://vmxplambardi:19086/teamworks/script/extjs/examples/ux');
外部要求([
“Ext.grid.*”,
“Ext.data.*”,
“Ext.ux.grid.FiltersFeature”,
“Ext.toolbar.Paging”
]);
var tableId=tableId+“-div”;
变量字段=[]、列=[]、数据索引=单元格';
变量过滤器={
ftype:'过滤器',
当地人:是的,
过滤器:[{
键入:“字符串”,
数据索引:“cell1”
}, {
键入:“字符串”,
数据索引:“cell2”
}, {
键入:“字符串”,
数据索引:“cell3”
}]
};
getElementById(tableId).innerHTML='';
for(var i=1;iJavascript没有块级作用域,因此for循环中定义的变量实际上是在函数顶部定义的(已提升),并在循环中生存。因此您总是覆盖变量。我让它这样工作:
var filters = {
ftype: 'filters',
// encode and local configuration options defined previously for easier reuse
encode: false, // json encode the filter query
local: true, // defaults to false (remote filtering)
// Filters are most naturally placed in the column definition, but can also be
// added here.
filters: [
{
type: 'boolean',
dataIndex: 'visible' //Just an example
}
]
};
var myFilterGrid = new Ext.create('Ext.ux.LiveSearchGridPanel', {
title: 'someTitle',
selType: 'cellmodel',
store: myStore,
columns:[
{
header: "Column1",
width: 90,
sortable: true,
dataIndex: 'INDEX1',
filterable: true, //<---
filter:{ //<---
type:'string'
}
},
....
{
header: "Another Column",
width: 85,
sortable: true,
dataIndex: 'INDEX2'
}],
features: [filters] //<---
});
希望这有帮助
'Ext.ux.grid.FiltersFeature'