3 Replies Latest reply on Aug 26, 2009 9:02 AM by Barna Biro

    Re:Item renderer AS3 for datagrid

    Venkat,Flex Developer

      I am having a data grid with multiple check boxes for this i am using CheckCellRendererEdit as itemrenderer.When i am making a change in datagrid checkbox its not updating

      The problems are

       

      1. when i select a checkbox in second row it gets selected in another  row after saving

      2.when i choose one checkbox in a row it gets afftected in many row can i get a solution for this Below given is the code i am using

       

      CheckCellRendererEdit.as


      package
      {
          import mx.controls.*;
      import mx.core.*;
      import mx.controls.dataGridClasses.DataGridListData;
      import flash.events.Event;
      import flash.events.MouseEvent;
      public class CheckCellRendererEdit extends CheckBox
      {
      // Define the constructor and set properties.
      public function CheckCellRendererEdit() {
          super();

       

      }
      override protected function clickHandler(event:MouseEvent):void
          {
                  if (!enabled)
                  {    //DataGrid(this.parentDocument.dg).selectedItem.vdata=CheckBox(event.currentTarget).selec ted;
                          event.stopImmediatePropagation();
                          return;
                  }                        
             
                  if (toggle)
                  {
                      selected = !selected;
                  }
                 
           }

       

      }

       

      }

        • 1. Re:Item renderer AS3 for datagrid
          Barna Biro Level 3

          Take a look at this: http://blog.wisebisoft.com/2009/05/09/working-with-item-renderers/ Your renderers are being reused and if you don't override certain methods that will "force" the update each time the data changes then the change won't be reflected immediately.

          • 2. Re:Item renderer AS3 for datagrid
            Venkat,Flex Developer Level 1

            Currently i am migrating from flex1.5 to flex2 Just i am using this itemrenderer(checkbox) for DataGrid can i have some ideas for datagrid

             

            The DataGrid i am using is

             

            <mx:DataGrid id="screendg" ">
                        <mx:columns>
                          <mx:Array>
                            <mx:DataGridColumn headerText="mdata" dataField="screenid" editable="false" />
                            <mx:DataGridColumn headerText="data" dataField="mdata" itemRenderer="CheckCellRendererEdit"  />
                            <mx:DataGridColumn headerText="mdata" dataField="vdata" itemRenderer="CheckCellRendererEdit"  />
                            <mx:DataGridColumn headerText="cdata" dataField="cdata" itemRenderer="CheckCellRendererEdit"  />
                            <mx:DataGridColumn headerText="vdata" dataField="udata" itemRenderer="CheckCellRendererEdit"  />

             

                        </mx:Array>
                        </mx:columns>
                      </mx:DataGrid>

             

             

            When i am selecting a checkbox in data grid the grid value is not getting changed

            • 3. Re:Item renderer AS3 for datagrid
              Barna Biro Level 3

              An item renderer is an item renderer, no matter if it's set to a DataGrid, a List or whatever. It work the same way for all the components. If you'll take the time to read and understand the example I just linked you to then you should be able to manage.