Flex - 如何在不触发AdvancedDataGrid的click事件的情况下单击列中的渲染链接按钮?

时间:2013-12-03 14:02:56

标签: flex itemrenderer advanceddatagrid

我有一个AdvancedDataGrid,其中有两列包含项呈示器。这些项呈示器在各自的列中呈现链接按钮。我希望能够单击这些链接按钮而不触发AdvancedDataGrid的itemClick事件。关于如何实现这一目标的任何建议?

1 个答案:

答案 0 :(得分:1)

我从未使用过AdvancedDataGrid,但我假设有一些原则。第一个是事件传播的行为。在网格处理事件之前,事件将由按钮处理。这意味着我们可以捕获并阻止事件到达DataGrid。下面是一个代码示例,演示了DataGrid渲染器如何在不触发其他行为的情况下使用Button。

CustomerRenderer...
<fx:Script>
    <![CDATA[
        protected function watchButtonClickHandler(event:MouseEvent):void
        {
                            //the line below stops the event from 
                            //propagating through the rest of the display
                            //list
            event.stopImmediatePropagation();
                            //handle button click logic here

        }
    ]]>
</fx:Script>
<s:Group width="100%" id="buttonGroup">
    <s:layout>
        <s:HorizontalLayout horizontalAlign="center" verticalAlign="middle"
                            paddingBottom="1" paddingLeft="1" 
                            paddingRight="1" paddingTop="1" />
    </s:layout>
    <s:Button id="watchButton" width="98" label="{buttonLabel}" 
                click="watchButtonClickHandler(event)"/>
</s:Group>
....
相关问题