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

问题描述


我使用下面的代码在弹性数据网格中使用链接按钮


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 中的解释示例,但它使用 default MouseEvent 您可以扩展 *MouseEvent* 类来保存您的自定义数据

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 - 获取链接按钮标签名称和数据网格的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 18:00