1 Reply Latest reply on May 7, 2010 10:17 AM by Flex harUI

    problem regarding multiple itemrender in same column.

    amol bhandwale

      <?xml version="1.0"?>
      <!-- itemRenderers\inline\CBInlineCellEditor.mxml -->
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
         
          <mx:Script>
              <![CDATA[
                  import mx.collections.ArrayCollection;
             
                  [Bindable]               
                  private var myDP:ArrayCollection = new ArrayCollection([
                      {label1:"Order #2314", contact:"John Doe",
                          quant:3, solddate:new Date(2005, 0, 1), Sent:true, CompInd : 0},
                      {label1:"Order #2315", contact:"Jane Doe",
                          quant:3, solddate:new Date(2005, 0, 5), Sent:false, CompInd : 1}
                  ]);
                 
              ]]>
          </mx:Script>
          <mx:DataGrid id="myDG"
                  dataProvider="{myDP}"
                  variableRowHeight="true"
                  width="600" height="250"
                  editable="true">
              <mx:columns>
                  <mx:DataGridColumn dataField="label1"
                      headerText="Order #"
                      editable="false"/>
                  <mx:DataGridColumn dataField="quant"
                      headerText="Quantity"
                      itemEditor="mx.controls.NumericStepper" 
                      editorDataField="value"/>
                  <mx:DataGridColumn dataField="solddate" headerText="Date"  itemRenderer="mx.controls.DateField" rendererIsEditor="true" editorDataField="selectedDate"/>
                  <mx:DataGridColumn dataField="Sent" editable="false" >
                  <mx:itemRenderer>
                          <mx:Component>
                          <mx:HBox>
                               <mx:Script>
                                   <![CDATA[
                                       private function fun1():void
                                       {
                                           if(data.Sent == true)
                                           {
                                               data.Sent = false;
                                           }
                                           else
                                           {
                                               data.Sent = true;
                                           }
                                           outerDocument.myDG.dataProvider.refresh();
                                       }
                                   ]]>
                               </mx:Script>
                               <mx:CheckBox change="fun1();" />
                          </mx:HBox>
                          </mx:Component>
                          </mx:itemRenderer>
                  </mx:DataGridColumn>
                  <mx:DataGridColumn dataField="solddate1" headerText="Col1" width="200" >
                      <mx:itemRenderer>
                          <mx:Component>
                              <mx:ViewStack selectedIndex="{data.Sent == true ? 0 : 1}" >
                                  <mx:HBox>
                                      <mx:DateField selectedDate="{data.solddate}"/>
                                  </mx:HBox>   
                                  <mx:HBox>
                                      <mx:TextInput text="{data.solddate.toString()}" width="150"/>
                                  </mx:HBox>
                              </mx:ViewStack>
                          </mx:Component>
                      </mx:itemRenderer>
                  </mx:DataGridColumn>
              </mx:columns >
          </mx:DataGrid> 
      </mx:Application>

       

       

       

       

      Problem ::

       

      In above example, I am showing datagrid where column "Col1" having multiple item renderers. On change of checkbox from "Sent" column, I am dynamically displaying either of the item renderers. i.e., if checkbox is false then datefield else textinput field.

       

      But when I type in text in textinput, then after outfocus still it displays that textinput in the datagrid cell. I want it to display only label in that cell.i want Same behaviour just like editable column when chkbox is select. and default show renderer in datagrid.

       

      Thanks,

      Amol