header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
member
Points:0
Posts:0

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



1
Brad
Points: 750
Posts:0
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


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 1+6 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions