How to get all row value of datgrid in flex when i click on any row and compare with other datagrid

1.5k views Asked by At

Actually i am new in flex my requirement is i have one datagrid which have 1 column name suppose it is (Name) this column has some value which is dynamic type what we want is we want all the row value when we click on any row then compare this datagrid with other datagrid when row value is match the check box get selected ..i wl be grateful if anybody can share any idea and links to me..

Thanks in advance

1

There are 1 answers

4
matilu On BEST ANSWER

If what you need is to capture all the selected object, you can do it in any event of the grid, or a link to a column renderer follows.

Anywhere in the code

var entireObj:Object = dgDemo.selectedItem

Since an event of the grid

private function eventGrid(e:Event):void
    {
        var entireObj:Object = e.currentTarget.selectedItem     
    }

If you need all column data

[Bindable] private var MyArray2:ArrayCollection = new ArrayCollection([ {Label:"Item1", Value:100}, 
        {Label:"Item2", Value:100},
        {Label:"Item3", Value:100},
        {Label:"Item4", Value:100},
        {Label:"Item5", Value:100} ]); 


    private function eventGrid(e:ListEvent):void
    {
        var entireObj:Object = e.currentTarget.selectedItem //ENTIRE ROW    
        var columLabelSelected:String = e.currentTarget.columns[e.columnIndex].dataField //COLUMN LABEL SELECTED
        var MyArray:Array = new Array(); //DATA ARRAY 
        for each(var objAux:Object in dgDemo.dataProvider) //FOR IN YOUR TYPE OBJECT
        {
            MyArray.push(objAux[columLabelSelected]) //ADD IN ARRAY DATA 
        }
    }


    ]]>
</mx:Script>

<mx:DataGrid id="dgDemo" dataProvider="{this.MyArray2}" itemClick="eventGrid(event)"/>