Ext JS 过滤呈现的列
Ext JS filtering rendered columns
我希望能够过滤我的每一列数据。每次过滤时,我都会使用:
addFilter({
dataIndex: 0, //Or 1,2.. depending on the column i want to filter on
type: 'string',
value: value,
});
这里的问题是我正在过滤的列的 dataIndex 是一个对象,所以我本质上是在过滤"对象"的文字字符串值。它是 Object,因为在我的存储中,我为每个 dataIndex 存储一个 Object,并使用 render
函数显示它。
单击标题触发器菜单,我为过滤器键入了一个文本框,如果您输入单词"对象"的任何字母,它就可以工作。如何让它过滤对象的值,而不是文字字符串' Object
https://fiddle.sencha.com/#fiddle/163s
你的type: 'string'
实际上说过滤器应该在字符串上工作。因此,该对象被字符串化为[object object]
,并与您提供的值进行比较。
相反,您需要使用自定义过滤器功能。在筛选器上使用 id 会很有用,因此同一列上的新版本会替换旧版本。
var dataIndex = column.dataIndex,
value = textfield.getValue();
grid.getStore().addFilter([{
id:"filter-"+dataIndex,
filterFn:function(record) {
// Example: Only return records where the object has a property by that name.
return Ext.Object.getKeys(record.get(dataIndex)).indexOf(value)>-1;
}
}]);
修改菜单更改侦听器
Ext.getCmp('myGrid').normalGrid.headerCt.getMenu().add({
xtype: 'textfield',
id: 'myT',
fieldLabel: 'Filter',
listeners: {
change: function(field, value) {
console.log([dataindexx, value]);
Ext.getCmp('myGrid').normalGrid.getStore().filterBy(function(r) {
if (!r.data[dataindexx].value.indexOf(value)) {
return true
};
});
if (value === '' || value === undefined) {
Ext.getCmp('myGrid').normalGrid.getStore().filters.removeAll();
}
}
}
});
相关文章:
- Angular JS-过滤ng重复
- 根据用户输入的leaflet.js过滤标记
- Angular Js过滤控制器中的嵌套数组
- Ext JS 过滤呈现的列
- 使用下划线.js过滤多维数组
- 角度JS过滤日期
- Ember.js过滤来自动态路由的数据
- Backbone.js-过滤集合与多个集合
- 使用Knockback.js过滤中的视图模型集合
- 如何使用角度 js 过滤数组
- 使用Underscore.js过滤具有条件的对象
- 无法使用Ember.js过滤图表
- D3.js过滤现有的html表
- Ember.js过滤内容并使用按钮操作
- js -过滤模型的所有属性
- 如何使用D3.js过滤数据
- 用angular js过滤项目
- 如何使用PHP和Angular JS过滤mySQL中的记录
- 用JS过滤表隐藏行
- 使用ramda.js过滤对象数组