tags:

views:

639

answers:

1

i created dynamically checkbox on data grid how do i find out Which checkbox select/unselect and which checkbox contact is select/unselect ? Because we cant set dynamic id for each checkbox

<mx:DataGrid x="7" y="3" width="347" height="337" dataProvider="{#####}" variableRowHeight="true">
    <mx:columns>
        <mx:DataGridColumn headerText="S.No" dataField="match_id" width="50"/>
        <mx:DataGridColumn headerText="Home" dataField="home_team" width="100"/>
        <mx:DataGridColumn headerText="Away" dataField="away_team" width="100"/>
        <mx:DataGridColumn headerText="1" >
            <mx:itemRenderer>
                <mx:Component>
         <mx:HBox verticalAlign="middle" paddingLeft="2">
                        <mx:CheckBox>
                        </mx:CheckBox>
                    </mx:HBox>
     </mx:Component>
 </mx:itemRenderer>
        </mx:DataGridColumn>
    <mx:DataGridColumn headerText="*" >
            <mx:itemRenderer>
                <mx:Component>
  <mx:HBox verticalAlign="middle" paddingLeft="2">
                        <mx:CheckBox>
                        </mx:CheckBox>
                    </mx:HBox>
     </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="2">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:HBox verticalAlign="middle" paddingLeft="2">
                        <mx:CheckBox>
                        </mx:CheckBox>
                    </mx:HBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
    </mx:columns>
</mx:DataGrid>
A: 

If you create a component for the itemRenderer instead of adding them the way they are represented above it would make things much clearer. Then, if that component implemented the IDropInListItemRender interface, you would be able to listen for events from the components on the DataGrid (here is a great article on the subject). Since the itemRenderer is based on the data in the DataGrid's dataProvider, you would have access to that information in a custom event you listen for.

in the itemRenderer component:

<mx:Checkbox id="myCheckbox" change="this.list.dispatchEvent(new CustomEvent(CustomeEvent.TYPE, myCheckbox.selected, this.data)) />

or something to that affect.

Joel Hooks
Thanks Joel Hooks . it's very useful . is it any easy method for create CheckBox and find out value
R.Vijayakumar