简体   繁体   中英

Click Event in a cell of a Flex Spark Datagrid

I have the following code:

<s:DataGrid id="preciosGrid" top="65" width="935" height="379" horizontalCenter="0" requestedRowCount="4"
            dataProvider="{clientModel.model.arrayColumnProducts}">
    <s:columns>
        <s:ArrayList>
            <s:GridColumn                           headerText="edit" width="30" itemRenderer="renderers.EditGridRender"></s:GridColumn>
            <s:GridColumn dataField="product"       headerText="Product" width="200" editable="false"></s:GridColumn>
            <s:GridColumn dataField="provider"  headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
        </s:ArrayList>
    </s:columns>
</s:DataGrid>

and need to be able to catch only the double-click event from the Edit cell (First column).

My itemRenderer is:

<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" clipAndEnableScrolling="true"
                width="50" height="30">

<fx:Script>
    <![CDATA[
        import events.EditItemEvent;

        import mx.controls.Alert;
        override public function prepare(hasBeenRecycled:Boolean):void {}
    ]]>
</fx:Script>
<s:Image id="btn_edit" horizontalCenter="0" source="@Embed('assets/images/edit_icon.png')"
         verticalCenter="0"
         doubleClickEnabled="true"
         doubleClick="Alert.show('clicked')"/>

How can I pass the click event to the main App from the ItemRenderer?

Thanks.

One way would be creating a EventListener inside you ItemRenderer, which dispatches a custom event where bubbling is set to true. And in you main application you can listen for that custom event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM