Flex 4 Datagrid itemrenderer

时间:2011-09-23 19:17:32

标签: flex datagrid flex4

我正在使用s:MXDataGridItemRenderer作为我的Datagrid。 ItemRenderer中的图像的click事件没有被调度。我在下面粘贴了我的代码。

ItemRenderer:

<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/mx"
                      focusEnabled="true">
<fx:Script>
    <![CDATA[
        private function acceptBtn_clickHandler(event:MouseEvent):void
        {
            updateData(false, "Accepted", 1);
        }
        private function updateData(approved:Boolean, buttonName:String, score:int):void
        {
            data.approved=approved;
            data.score=score;
            data.decisionText=buttonName;
        }
        private function rejectBtn_clickHandler(event:MouseEvent):void
        {
            updateData(false, "Rejected", 1);
        }

    ]]>
</fx:Script>
<mx:HBox id="imageBox"
         horizontalAlign="center"
         verticalAlign="middle"
         width="100%"
         height="100%"
         enabled="true"
         >
    <mx:Image id="acceptBtn"
              source="@Embed(source='../../../assets/icons/button-accept.png')"
              click="acceptBtn_clickHandler(event)"
              buttonMode="true"
              toolTip="Accept"/>
    <mx:Image id="rejectBtn"
              source="@Embed(source='../../../assets/icons/button-reject.png')"
              click="rejectBtn_clickHandler(event)"
              buttonMode="true"
              toolTip="Reject"/>
</mx:HBox>

的Datagrid:

<mx:DataGrid id="testList"
             dataProvider="{testListDP}"
             width="100%"
             height="100%"
             editable="true">
    <mx:columns>
        <mx:DataGridColumn dataField="score"
                           headerText="Score"
                           editable="false"/>
        <mx:DataGridColumn headerText="Decision"
                           itemRenderer="DecisionColumnItemRenderer"
                           editable="false"/>
    </mx:columns>
</mx:DataGrid>

0 个答案:

没有答案