选择Cell datagrid flash builder

时间:2013-02-03 03:28:10

标签: datagrid flash-builder cell

基本上我想要做的只是选择一个单元格,并让有关该单元格的信息显示为其下方框中的标签。

enter image description here

这就是我现在所拥有的:

    <s:DataGrid selectionMode="multipleCells" x="726" y="0" width="446" height="50" requestedRowCount="0" click="itemClickEvent(event)">
                        <s:columns>
                            <s:ArrayList>
                                <s:GridColumn width="63" dataField="dataField1" headerText="見積条件"></s:GridColumn>
                                <s:GridColumn width="63" dataField="dataField2" headerText="原価見積"></s:GridColumn>
                                <s:GridColumn width="63" dataField="dataField3" headerText="見積作成"></s:GridColumn>
                                <s:GridColumn width="63" dataField="dataField4" headerText="見積発行"></s:GridColumn>
                                <s:GridColumn width="63" dataField="dataField5" headerText="受注失注"></s:GridColumn>
                                <s:GridColumn width="63" dataField="dataField6" headerText="納品"></s:GridColumn>
                                <s:GridColumn width="63" dataField="dataField7" headerText="請求"></s:GridColumn>
                            </s:ArrayList>
                        </s:columns>

                        <s:ArrayList>
                            <fx:Object dataField1="2" dataField2="1" dataField3="2" dataField4="1" dataField5="4" dataField6="1" dataField7="1"></fx:Object>
                        </s:ArrayList>
                    </s:DataGrid>

private function itemClickEvent(event:Event):void
            {
                currentState='information_dropdown'
                Alert.show("Row : " +event.rowIndex + "Column : " +event.columnIndex)



            }

虽然代码显示了一个警告框,但我希望将其显示为其下的标签。我在rowIndex和columnIndex部分遇到错误。

任何建议都会很棒。

1 个答案:

答案 0 :(得分:0)

不要在datagrid上侦听click事件,而是侦听GridEvent.GRID_CLICK:

<s:DataGrid selectionMode="multipleCells" x="726" y="0" width="446" height="50" requestedRowCount="0" gridClick="itemClickEvent(event)">

将侦听器参数类型更改为GridEvent:

private function itemClickEvent(event:GridEvent):void
{
    ...
}
然后

rowIndex和columnIndex应该给出正确的结果。