0

Basically what I want to do is to select just one cell, and let the information about that cell being displayed as either a label in the box under it.

enter image description here

This is what I have at the moment:

    <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)



            }

Although the code shows an alert box I want to display it as a label under it instead. I do get an error on the rowIndex and columnIndex part.

Any advice would be great.

4

1 回答 1

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 应该给出正确的结果。

于 2013-02-03T17:00:17.503 回答