flex中使dataGrid每行都有button

來源:互聯網
上載者:User

標籤:

使dataGrid中每行都有button,且在點擊button時知道點擊的是哪行的button。

代碼如下:

<mx:DataGrid id="dg" editable="true" color="0x323232" width="100%" height="450" rowCount="32" rowHeight="40" dataProvider="{dataIndicator}">            <mx:columns>                <mx:DataGridColumn dataField="indexIndicator" width="50" headerText="序號" textAlign="center" editable="false"/>                 <mx:DataGridColumn dataField="INDICATOR_VALUE" headerText="指標值" editable="true"/>                  <mx:DataGridColumn editable="false" width="120" itemRenderer="">                    <mx:itemRenderer>                        <fx:Component>                            <mx:HBox width="100" horizontalAlign="center" verticalAlign="top">                                                                <mx:Button label="保    存" width="80" click="outerDocument.button1_clickHandler(event)">                                                                        <fx:Script>                                        <![CDATA[                                            protected function button1_clickHandler(event:MouseEvent):void                                            {                                                // TODO Auto-generated method stub                                                                                                                                            }                                        ]]>                                    </fx:Script>                                                                    </mx:Button>                                                            </mx:HBox>                        </fx:Component>                    </mx:itemRenderer>                </mx:DataGridColumn>            </mx:columns>        </mx:DataGrid>

自動產生的button的click方法沒有在原頁面上,所以無法調用dataGrid中selectedIndex,所以需要引用outerDocument.的方法,這樣就能訪問到外面的方法,此時可以刪掉<mx:Button>中間的<fx:Script>,直接調用外面的方法了

 

flex中使dataGrid每行都有button

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.