PDA

View Full Version : grid filter list options: does it do exact match search?



shankar8rajah1
1 Nov 2013, 8:00 AM
I was wondering when you do a list options for the filter, does it do an exact match on the strings in a column? If so, is there a way to override and peform anymatch on it?

I have cells that has values like:

DMA=[1,2,3]
Engines=[1,3,5]

When I do the list options, I get nothing for the filter, but when I use a combo box like below, it finds them.



family = ["","Analytics", "Client Connectivity", "Crossing", "DMA", "ETR", "Engines", "Monitoring", "TP Monitoring", "Tick", "Tradeserver"];

var familyCombo = Ext.create('Ext.form.field.ComboBox', {
fieldLabel: 'Family',
allowBlank: true,
multiSelect: false,
width: 190,
labelWidth: 40,
store: family,
queryMode: 'local',
listeners: {
select: function(combo, record, index) {
grid.store.clearFilter();
grid.store.filter('instances',combo.getValue());
grid.store.load();

}
}
});

scottmartin
4 Nov 2013, 1:12 PM
See:
http://www.sencha.com/forum/showthread.php?275186

shankar8rajah1
4 Nov 2013, 5:22 PM
Hi Scott,

I figured out with your help in the other thread how to make my own filter function for the combobox. However, I am a bit lost as to where to put the same function for the filter options in the menu. Can I put them in this section since I only want to do it on one column:


var filters = {
ftype: 'filters',
// encode and local configuration options defined previously for easier reuse
encode: encode, // json encode the filter query
local: local, // defaults to false (remote filtering)
filters: [{
type: 'list',
dataIndex: 'name',
options: name_column
}, {
type: 'list',
dataIndex: 'service_group',
options: service_group_column
}, {
type: 'list',
dataIndex: 'app_name',
options: app_name_column
},{
type: 'list',
dataIndex: 'env',
options: env_column
}]
};

shankar8rajah1
14 Nov 2013, 3:58 PM
any help on this?

scottmartin
14 Nov 2013, 4:07 PM
Not sure I understand your last requirement, do you mean create a custom menu option to filter the data?



Ext.onReady(function(){

Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' },

{
xtype: 'actioncolumn',
width:30,
sortable: false,
items: [{
icon: '../icons/accept.png',
itemId: 'my-action-column',
tooltip: 'Tooltip',
iconCls: 'handicon',
handler: function (grid, rowIndex, colIndex) {

}
}]
}

],
height: 200,
listeners: {
afterrender: function() {
var menu = this.headerCt.getMenu();
menu.add([{
text: 'Custom Item',
handler: function() {
var columnDataIndex = menu.activeHeader.dataIndex;
alert('custom item for column "'+columnDataIndex+'" was pressed');
}
}]);
}
},
width: 400,
renderTo: Ext.getBody()
});

});


If this is not the case, then please elaborate on what you are trying to achieve.

shankar8rajah1
14 Nov 2013, 5:03 PM
Not a custom menu option.

Say for the dataIndex 'name', I am using a list filter option with the following options [DMA, Engines].

This will give me checkbox in the menu for the Name column with DMA and Engines. If I check DMA, I want it to do my reg exp function.

The reason is that currently if I check DMA, it returns nothing because my cell has {DMA=[1,2,3] Engines = [3,4,5]} and I am assuming it does an exact match and therefore DMA is not equal to {DMA=[1,2,3] Engines = [3,4,5]}

shankar8rajah1
15 Nov 2013, 7:35 AM
hi,

I was able to do this with the following code:



{
type: 'list',
dataIndex: 'filer_mounts',
options: filer,
validateRecord: function(record) {
var valuesArray = this.getValue(),
r = record.get(this.dataIndex),
i, re, retval = false;


for(i in valuesArray) {
re = new RegExp(valuesArray[i], 'gi');
if(re.test(r)) {
retval = true;
}
}
return retval;
}
}