在Col1列的'MyGrid'中,我将来自商店True或False的值更改为Yes(对于True)和No(对于false)。如果我没有在过滤器下指定任何选项,则过滤器列表显示为True,False。我想使用Yes(For True)和No(For False)进行本地过滤。我该如何实现这一目标?
Ext.define('TestGrid', {
requires: [
'Ext.ux.grid.FiltersFeature'
],
extend: 'Ext.grid.Panel',
initComponent: function() {
var myStore = Ext.create('MyStore');
this.columns = [
{
text: 'Col1',
dataIndex: 'Col1',
sortable: true,
draggable: false,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
//changing from true/false to yes/no
if (value) {
return 'Yes';
} else {
return 'No;
}
}
}
];
this.features = [
{
ftype: 'filters',
local: true,
encode: false,
filters: [
{
type: 'list',
dataIndex: 'Col1',
options: ['Yes', 'No'],
phpMode: true
}
]
}
];
this.callParent(arguments);
}
});
答案 0 :(得分:0)
有一个解决方案!
validateRecord: function(record) {
var valArray = this.getValue(), rec = record.get(this.dataIndex), i, re, retval = false, changedValues = [];
//for each values in valArray add appropriate value in changedVal //for Yes -> True and No -> False
for(i in changedValues) {
re = new RegExp(changedValues[i], 'gi');
if(re.test(rec)) {
retval = true;
}
}
return retval;
}
答案 1 :(得分:0)
更容易(想知道为什么我之前没有尝试过)
{
type: 'list',
dataIndex: 'Col1',
options: [
[true,'Yes'],
[false, 'No']
}