我的 Datagrid 有以下代码:
<s:DataGrid id="proveedoresGrid" top="10" bottom="10" width="426"
creationComplete="proveedoresGrid.addEventListener('editIconClicked', itemRendererEditClickHandler);proveedoresGrid.addEventListener('deleteIconClicked', btn_eliminar_proveedor_clickHandler);"
dataProvider="{proveedoresModel.modelo.arrayProveedores}"
gridClick="editProveedor(event)"
horizontalCenter="-255" requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn headerText="Edit" width="50" itemRenderer="renderers.EditGridRender" rendererIsEditable="false"></s:GridColumn>
<s:GridColumn dataField="proveedor" headerText="Proveedor" width="370" editable="false"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
好吧,在第一列中,我有一个 itemrenderer,它显示两个图标“编辑和删除”,并且根据图标点击,它调度一个事件。问题是这样的Datagrid 还有另一个通用事件“gridClick”。一旦我单击第一列中的单元格,“gridClick”事件始终有效,并且应该适用于不属于第一列的任何其他单元格。
我怎么能做到这一点?
谢谢。
编辑:
项目渲染器:
<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:Metadata>
[Event(name="editIconClicked")]
</fx:Metadata>
<fx:Script>
<![CDATA[
import events.EditItemEvent;
import mx.controls.Alert;
import mx.controls.DataGrid;
override public function prepare(hasBeenRecycled:Boolean):void {}
protected function btn_edit_clickHandler(event:MouseEvent):void {
event.stopImmediatePropagation();
event.stopPropagation();
dispatchEvent(new Event("editIconClicked", true, true));
}
protected function btn_delete_clickHandler(event:MouseEvent):void {
event.stopImmediatePropagation();
event.stopPropagation();
dispatchEvent(new Event("deleteIconClicked", true, true));
}
]]>
</fx:Script>
<s:HGroup width="100%" height="24" top="3" gap="1">
<s:Image id="btn_edit" horizontalCenter="0"
source="@Embed('assets/images/edit_icon.png')"
verticalCenter="0"
click="btn_edit_clickHandler(event)"/>
<s:Image id="btn_delete" horizontalCenter="0"
source="@Embed('assets/images/delete_icon.png')"
verticalCenter="0"
click="btn_delete_clickHandler(event)"/>
</s:HGroup>