グリッド列リスト フィルタを複数選択コンボに置き換えたい場合は、以下のコードを使用します...
/**
* Filter by a configurable app.view.common.tag.Tag
* <p><b><u>Example Usage:</u></b></p>
* <pre><code>
var filters = Ext.create('Ext.ux.grid.GridFilters', {
...
filters: [{
// required configs
type : 'combofilter',
dataIndex : 'myName',
options : ['aa','bb']
// optional configs
allowBlank: false, //default is true
fieldLabel: "Tag(s)"
...
}]
});
* </code></pre>
*/
Ext.define('Ext.ux.grid.filter.ComboFilter', {
extend: 'Ext.ux.grid.filter.Filter',
alias: 'gridfilter.combofilter',
/**
* @cfg {String} iconCls
* The iconCls to be applied to the menu item.
* Defaults to <tt>'ux-gridfilter-text-icon'</tt>.
*/
iconCls : 'ux-gridfilter-text-icon',
emptyText: 'Enter Filter Text...',
selectOnFocus: true,
width: 125,
/**
* @private
* Template method that is to initialize the filter and install required menu items.
*/
init : function (config) {
Ext.applyIf(config, {
allowBlank: true,
queryMode: 'local',
displayField : 'name',
valueField : 'id',
store: (config.options == null ? [] : config.options),
multiSelect: true,
typeAhead: true,
itemId: 'valuesSelect',
emptyText : 'Select',
labelWidth: 29,
fieldLabel: '',
width: 300,
listeners: {
scope: this,
//keyup: this.onInputKeyUp,
el: {
click: function(e) {
e.stopPropagation();
if (e.updateTask !== undefined) {
e.updateTask.delay(this.updateBuffer);
}
}
},
change: this.changeSelection
}
});
this.inputItem = Ext.create('app.view.common.tag.Tag', config);
this.menu.add(this.inputItem);
this.menu.showSeparator = false;
this.updateTask = Ext.create('Ext.util.DelayedTask', this.fireUpdate, this);
},
/**
* @private
* Template method that is to get and return the value of the filter.
* @return {String} The value of this filter
*/
getValue : function () {
return this.inputItem.getValue();
},
/**
* @private
* Template method that is to set the value of the filter.
* @param {Object} value The value to set the filter
*/
setValue : function (value) {
this.inputItem.setValue(value);
this.fireEvent('update', this);
},
/**
* Template method that is to return <tt>true</tt> if the filter
* has enough configuration information to be activated.
* @return {Boolean}
*/
isActivatable : function () {
return this.inputItem.getValue().length > 0;
},
/**
* @private
* Template method that is to get and return serialized filter data for
* transmission to the server.
* @return {Object/Array} An object or collection of objects containing
* key value pairs representing the current configuration of the filter.
*/
getSerialArgs : function () {
return {type: 'list', value: this.getValue()};
},
/**
* Template method that is to validate the provided Ext.data.Record
* against the filters configuration.
* @param {Ext.data.Record} record The record to validate
* @return {Boolean} true if the record is valid within the bounds
* of the filter, false otherwise.
*/
validateRecord : function (record) {
var val = record.get(this.dataIndex);
if(typeof val != 'list') {
return (this.getValue().length === 0);
}
return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
},
changeSelection: function(field, newValue, oldValue) {
if (this.updateTask !== undefined) {
this.updateTask.delay(this.updateBuffer);
}
}
});
ExtJs の Tag プラグインを使用し、FiltersFeature に ComboFilter ファイルを追加する必要があります。お気に入り ...
Ext.define('Ext.ux.grid.FiltersFeature', {
extend: 'Ext.grid.feature.Feature',
alias: 'feature.filters',
uses: [
'Ext.ux.grid.menu.ListMenu',
'Ext.ux.grid.menu.RangeMenu',
'Ext.ux.grid.filter.BooleanFilter',
'Ext.ux.grid.filter.DateFilter',
'Ext.ux.grid.filter.DateTimeFilter',
'Ext.ux.grid.filter.ListFilter',
'Ext.ux.grid.filter.NumericFilter',
'Ext.ux.grid.filter.StringFilter',
'Ext.ux.grid.filter.ComboFilter'
],
のように見えます...
ここに画像の説明を入力