0 Replies Latest reply on Apr 12, 2010 1:32 PM by Zolotoj

    Complex custom itemrenderer

    Zolotoj Level 3

      I have the following custom renderer (comboBoxCheckItemRendererDataGridDynamic.mxml) for one of datagrid columns:

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:ComboBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
                      xmlns:s="library://ns.adobe.com/flex/spark" 
                      xmlns:mx="library://ns.adobe.com/flex/mx">
           <fx:Script>
                <![CDATA[
                import mx.events.FlexEvent;
                import mx.collections.ArrayCollection;
                import mx.controls.CheckBox;
                public var datas:XML;
                [Bindable]
                var ItemRenderer:ClassFactory;     
                override public function set data(value:Object):void
                {
                     dataProvider = datas["sku" + value.sku];
                }               
                public function saveCheckState(evt:Event):void
                {
                     var dataProviderItem:Object = dataProvider.getItemAt(dataProvider.getItemIndex(selectedItem));
                     dataProviderItem.selected = CheckBox(evt.currentTarget).selected;
                     dataProvider.setItemAt(dataProviderItem, dataProvider.getItemIndex(selectedItem));     
                }
                ]]>
           </fx:Script>
           <mx:itemRenderer>
                <fx:Component>
                     <mx:HBox width="100%">
                          <mx:Label text="{XML(data).action}"/>
                          <mx:Spacer width="100%"/>
                          <mx:CheckBox id="check" selected="{XML(data).selected == 'true'}"
                                          change="outerDocument.saveCheckState(event);"/>
                     </mx:HBox>
                </fx:Component>
           </mx:itemRenderer>
      </mx:ComboBox>
      
       
      In the main program I am setting this custom renderer up as the following:
      ...
      [Bindable]
      var plannedAtions:ClassFactory = new ClassFactory(comboBoxCheckItemRendererDataGridDynamic);
      ...
      plannedAtions.properties = {labelField : "action", datas : resultXML};          
      column.itemRenderer = plannedAtions;
      ...
       
      The custom renderer is shown fine for existing rows but for newly added it shows empty combo.
      Any idea?
       
      Thanks