5/11/2010 10:50:09 PM
Title:
filtering datagrid depending on columns..
Hi,
I have advanced data grid with four columns..
And i have four combo box.
i have to filter the data grid entries like, when i select value of first cobobox grid should filter according to its first column matches with combobox value...
when i select second combobox, datagrid should filter according to second column value and so on..
I tried with regular expression .. but its not working as i required..
Here is my code..
<mx:DataGrid id="kpiname" dataProvider="{kpiGrid}" x="83" y="217" height="198" width="303">
<mx:columns>
<mx:DataGridColumn headerText="Dept" dataField="dept"/>
<mx:DataGridColumn headerText="group" dataField="group"/>
<mx:DataGridColumn headerText="level" dataField="level"/>
<mx:DataGridColumn headerText="KPI" dataField="kpi"/>
</mx:columns>
</mx:DataGrid>
<mx:ComboBox x="97" y="119" width="115" prompt="Select Dept" id="dept" change="getDepartment(event)"></mx:ComboBox>
<mx:ComboBox x="98" y="174" width="115" prompt="Select Level" id="kpilevel" change="getLevel(event)"></mx:ComboBox>
<mx:ComboBox x="275" y="119" prompt="Select Group" width="111" id="group" change="getGroup(event)"></mx:ComboBox>
<mx:script>
private function getDepartment(event:Event):void{
if(dept.selectedLabel)
{
filtervariable = dept.selectedLabel;
if (filtervariable.length == 0) {
kpiGrid.filterFunction = null;
} else {
kpiGrid.filterFunction = filter_Function;
}
kpiGrid.refresh();
//kpiname.dataProvider=kpiGrid.refresh();
}
}
private function filter_Function(item:Object):Boolean {
if (filtervariable.length == 0) return true;
var d:String = "f";
var deptRegExp:RegExp = new RegExp(filtervariable, d);
var deptMatch:Boolean =deptRegExp.test(item.dept);
return (deptMatch );
}
</mx:script>
but this code will match values in all columns of datagrid ..but i want to compare it with perticular column..
Im not at all getting any idea for this even after searching in google from week..please help me in coding..pls pls..
its urgent
Thanks in advance
5/12/2010 3:38:54 AM
I have answered a similar thread to apply filter to a column of datagrid in flex
http://askmeflash.com/qdetail/650/please-its-urgent