Edit/Delete buttons in Flex Datagrid
I have a flex datagrid with cart items populated from a service. Each row has edit/delete buttons provided by a custom ItemRenderer. When I click each button I send an even开发者_开发技巧t from the itemrenderer which calls a service in order to edit/delete the selected item.
How can I get the id of the product form the dataprovider inside the Itemerenderer in order to send it with my custom event?
Thanks in advance
Use the DATA property of the itemRenderer.
The Flex help has a very illustrative example. If your dataProvider is:
<mx:ArrayList>
<fx:Object firstName="Bill" lastName="Smith" companyID="11233"/>
<fx:Object firstName="Dave" lastName="Jones" companyID="13455"/>
<fx:Object firstName="Mary" lastName="Davis" companyID="11543"/>
<fx:Object firstName="Debbie" lastName="Cooper" companyID="14266"/>
</mx:ArrayList>
you can access the data item as follows:
<?xml version="1.0" encoding="utf-8"?>
<!-- containers\spark\myComponents\MySimpleItemRenderer.mxml -->
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<s:HGroup verticalCenter="0" left="2" right="2" top="2" bottom="2">
<s:Label text="{data.lastName}, {data.firstName}"/>
<s:Label text="{data.companyID}"/>
</s:HGroup>
</s:ItemRenderer>
精彩评论