PDA

View Full Version : Ext 4.2 Grid filter on one column with multiple values



bharadwaj_divya
30 Jul 2015, 3:08 AM
Hi Guys,

I am new to ExtJS. I am trying to filter out data which is rendered to grid.
what i need is that, there is a column called "Status" which can have"CLOSED" or "OPEN" or "N/A" status for a row.

I have a checkbox which says "Show Closed Status" outside the grid which is on top of the page. By default it should be unchecked and the the grid should be filtered by "OPEN" and "N/A" status rows and when I Check this field it should show all status i.e. "CLOSED", "OPEN" and "N/A" rows.

Please help me with this issue that i am facing with.

Thanks in advance.

Looking forward to hear from you guys.

scottmartin
30 Jul 2015, 1:51 PM
You would need to setup a renderer for the column to where the value is checked and the value returned is the string you want.
http://docs.sencha.com/extjs/4.2.4/#!/api/Ext.grid.column.Column-cfg-renderer

There is also the option to have a convert field to alter your data:
http://docs.sencha.com/extjs/4.2.4/#!/api/Ext.data.Field-cfg-convert

Yet another option is to return the string from the per a sql join is that is an option.

Scott.

bharadwaj_divya
31 Jul 2015, 12:39 AM
Thank you very much Scott.

With the solution you gave I found an alternate solution for this.
based on the value of the check box field I will filter using below code,


grid.store.filterBy(function(rec) {
var value = rec.get('status');
return (value != 'CLOSED');
},this);

This filters out all the values except "CLOSED" status.