本文介绍了flex - 获取linkbutton标签名称和所选的datagrid行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在flex datagrid中使用linkbutton


i am using below code for using linkbutton in flex datagrid

<mx:DataGridColumn headerText="Case ID" width="80">
                    <mx:itemRenderer>
                        <fx:Component>
                            <mx:Canvas>
                                <mx:LinkButton id="lnkCaseId" click="outerDocument.lnkCaseIdClick(event)" label="{data.caseId}" textDecoration="underline" color="#0052A5">
                                </mx:LinkButton>
                            </mx:Canvas>
                        </fx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn><br/>

现在在链接按钮上点击我想要的链接标签名称和选择行 lnkCaseIdClick 方法,我该怎么做????谢谢。

now on link button click i want linkbutton label name and selected row inside lnkCaseIdClick method, how can i do this?
thanks.

推荐答案

这里是根据 @J_A_X ,但使用默认 MouseEvent 您可以 extent * MouseEvent strong>自定义数据

Here is sample according to explanation in @J_A_X but its using default MouseEvent You can extent *MouseEvent* Class to hold your custom data

<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    click="{clicked(event)}">
    <mx:Script>
        <![CDATA[
            import mx.controls.LinkButton;
            import mx.core.UIComponent;
            import mx.controls.Alert;
            public function clicked(event:MouseEvent):void
            {
                if (event.target is LinkButton)
                {
                    var innerLinkButon:LinkButton = event.target as LinkButton;
                    Alert.show("Application : "+innerLinkButon.label);
                }
            }
        ]]>
    </mx:Script>
    <mx:DataGrid id="grid">
        <mx:dataProvider>
            <mx:ArrayCollection>
                <mx:Array>
                    <mx:Object label="AAAA"/> 
                    <mx:Object label="BBBB"/>
                    <mx:Object label="CCCC"/>
                    <mx:Object label="DDDD"/>
                </mx:Array>
            </mx:ArrayCollection>
        </mx:dataProvider>
        <mx:columns>
            <mx:DataGridColumn id="columnA" headerText="columnA" dataField="@label">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:LinkButton click="{clicked(event)}" label="{data.label.toString()}">
                            <mx:Script>
                                <![CDATA[
                                    import mx.controls.Alert;

                                    public function clicked(event:MouseEvent):void
                                    {
                                        Alert.show("linkButton");
                                    }

                                ]]>
                            </mx:Script>
                        </mx:LinkButton>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
        </mx:columns>
    </mx:DataGrid>
</mx:Application>

希望有助于

这篇关于flex - 获取linkbutton标签名称和所选的datagrid行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 15:23