0

I'm using a spark Datagrid in an mobile Flex (4.6) application. When a row is selected in the grid I want to trigger a function and use the content of the selected item in that same function. This is my Datagrid

<s:DataGrid id="patientGrid" x="317" y="211" width="393" height="177"
            dataProvider="{patientInfo}" gridClick="patientSelect(event)">
    <s:columns>
        <s:ArrayList>
            <s:GridColumn dataField="FirstName" headerText="First Name"/>
            <s:GridColumn dataField="LastName" headerText="Last Name"/>
            <s:GridColumn dataField="DateOfBirth" headerText="Date Of Birth"/>
            <s:GridColumn dataField="Gender" headerText="Gender"/>
        </s:ArrayList>
    </s:columns>
</s:DataGrid>

And when a item is selected the patientselected function needs the ability to work with the content of that selected item.

I hope my question is clear, and thanks for helping!

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Tommyke
  • 37
  • 9

1 Answers1

1

Use the GridSelectionEvent.SELECTION_CHANGE event instead for two reasons:

  • it will provide information on which cells have been selected
  • it is fired whenever the selection changes (if you only react on mouse clicks, you ignore keyboard navigation/selection)

.

<s:DataGrid id="dg" selectionChange="onSelectionChange(event)" />

private function onSelectionChange(event:GridSelectionEvent):void {
    var index:int = event.selectionChange.rowIndex;
    var patient = dg.dataProvider.getItemAt(index);
    patientSelect(patient);
}
RIAstar
  • 11,912
  • 20
  • 37