Hi, Read about filterFunction in ArrayCollection. You will get to know about how to filter things in collections.
-Ravi http://achieveravi.blogspot.com On Aug 18, 8:14 am, itonflex team <itonflext...@gmail.com> wrote: > Hi friends, this is kishore ! > I have a dynamic datagrid, i need to do the searching and > filtering both for that datagrid.. Could you please help me regarding > that please...................... > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > width="100%" height="100%" > horizontalScrollPolicy="off" verticalScrollPolicy="off" > creationComplete="load();" cornerRadius="10" xmlns:local="*"> > > <mx:Script> > <![CDATA[ > > public function load():void > { > > hs1.send(); > init(); > } > > import mx.controls.Text; > import mx.controls.Label; > import mx.containers.HBox; > import mx.controls.Alert; > import mx.rpc.events.ResultEvent; > import mx.controls.dataGridClasses.DataGridColumn; > import mx.controls.DataGrid; > import mx.collections.XMLListCollection; > import mx.controls.Alert; > > public var hbx1:HBox=new HBox(); > public var lab:Label=new Label(); > public var hbx2:HBox=new HBox(); > public var txt:Text=new Text(); > public var lab1:Label=new Label(); > public var hbx3:HBox=new HBox(); > > [Bindable] > public var x1:XMLList = new XMLList(); > > public function init():void > { > initApp(); > } > [Bindable] > private var _xlcCatalog:XMLListCollection; > > public function initApp():void > { > _xlcCatalog = new XMLListCollection > (x1.record); > } > > [Bindable] > public var dg:DataGrid = new DataGrid(); > > private function myfun(event:ResultEvent):void > { > //Alert.show(event.result.toString()); > dg.percentWidth=100; > dg.percentHeight=100; > dg.setStyle("fontSize","15"); > _xlcCatalog = new > XMLListCollection(event.result..iton); > var aColumnDef:Array = > getColumnDefArray(event); > var oColumnDef:Object; > > var dgc:DataGridColumn; > var dgc1:DataGridColumn; > var aColumnsNew:Array = dg.columns; > var iTotalDGWidth:int = 0; > for (var i:int=0;i<aColumnDef.length;i++) > { > oColumnDef = aColumnDef[i]; > dgc = new DataGridColumn(); > dgc.dataField = oColumnDef.dataField; > aColumnsNew.push(dgc) > } > > //dgc1 = new DataGridColumn(); > //iTotalDGWidth += dgc1.width; > // aColumnsNew.push(dgc1); > > dg.columns = aColumnsNew; > dg.columns.autoResize=true; > > //DataGridColumn(dg.columns[2]).resizable=true; > x1=event.result..iton; > //Alert.show(x1+'xlist'); > dg.dataProvider = x1; > dg.wordWrap=true; > //dg.cornerRadius=10; > //this.addChild(dg); > dyndgbox.addChild(dg); > > }//buildDG > > public var node0:XML > private function > getColumnDefArray(event:ResultEvent):Array > { > //Alert.show(event.result..iton.length()+'') > if(event.result..iton.length==0) > { > Alert.show('No Data Found'); > } > var aColumns:Array = new Array(); > var node0:XML = event.result..iton[0]; > var xlColumns:XMLList = node0.children(); > var xmlColumn:XML > var oColumnDef:Object; > for (var i:int=0;i<xlColumns.length();i++) > { > xmlColumn = xlColumns[i]; > //xmlColumn.wordWrap=true; > oColumnDef = new Object(); > //oColumnDef.wordWrap=true; > oColumnDef.dataField = > xmlColumn.localName(); > aColumns.push(oColumnDef); > } > return aColumns; > } > > ]]> > </mx:Script> > <mx:HTTPService id="hs1" url="labels.xml" result="myfun(event)" > resultFormat="e4x" fault="Alert.show(event.fault.toString());" /> > <mx:VBox width="100%" height="100%" verticalGap="0" cornerRadius="10" > > <mx:HBox width="100%" height="38" id="searchprintbox" > cornerRadius="10" borderStyle="solid" verticalAlign="middle" > horizontalAlign="right"> > <mx:TextInput id="txtSearch"/> > <mx:Button label="Search" id="btnSearch"/> > </mx:HBox> > <mx:VBox width="100%" height="100%" id="dyndgbox" > cornerRadius="10" / > > </mx:VBox> > <mx:XMLListCollection id="xmllicol" /> > </mx:Application> > > labels.xml > ------------------------------------------------------------------- > > <xml> > <iton> <name>kishore</name> <address>tanuku</address></iton> > <iton> <name>Nag</name> <address>paidiparru</address></iton> > <iton> <name>aasha</name> <address>jrgudem</address></iton> > <iton> <name>vasanth</name> <address>murari</address></iton> > <iton> <name>raaz</name> <address>nizamabad</address></iton> > <iton> <name>praveen</name> <address>hyd</address></iton> > <iton> <name>srinu</name><address>siddhantam</address></iton> > </xml> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to flex_india@googlegroups.com To unsubscribe from this group, send email to flex_india+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---