0

我在移动 Flex (4.6) 应用程序中使用 spark 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>

当一个项目被选中时,patientselected 函数需要能够处理该选定项目的内容。

我希望我的问题很清楚,并感谢您的帮助!

4

1 回答 1

1

使用GridSelectionEvent.SELECTION_CHANGE事件有两个原因:

  • 它将提供有关已选择哪些单元格的信息
  • 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);
}
于 2012-05-07T11:59:10.233 回答