2 Replies Latest reply on Feb 19, 2010 8:11 AM by JockMahon

    checkbox in a Datagrid

    JockMahon Level 1

      can anyone tell me why as soon as it resize the grid columns all the check boxes loss their values

       

       

       

      <mx:DataGrid id="itemsGrid"

      dataProvider="

      {items}"

      wordWrap="

      true"

      right="

      0" left="0" top="0" bottom="80"

      editable="

      true">

       

       

      <mx:columns>

       

       

      <mx:DataGridColumn headerText=""

      dataField="

      itemChecked"

      width="

      20"

      minWidth="

      20"

      itemRenderer="

      mx.controls.CheckBox"

      editorDataField="

      selected"

      rendererIsEditor="

      true"

      editable="

      true"/>

       

       

       

      <mx:DataGridColumn headerText="Qty"

      dataField="

      qty"

      width="

      40"

      minWidth="

      40"

      editable="

      false"/>

       

      </mx:DataGrid>

       

      thanks

        • 1. Re: checkbox in a Datagrid
          Gregory Lafrance Level 6

          It's because itemRenderers are recycled in Flex.

           

          Try using this code (modified for your situation) for the itemRenderer:

           

            <mx:AdvancedDataGridColumn dataField="FLAG" headerText="I" width="20" textAlign="center">
              <mx:itemRenderer>
                <mx:Component>
           <mx:CheckBox selectedField="FLAG" change="onChange(event);" label="">
             <mx:Script>
               <![CDATA[
                 private function onChange(evt:Event):void {
            data.FLAG = !data.FLAG;
            outerDocument.calculateTotals();
                 }
               ]]>
             </mx:Script>
           </mx:CheckBox>
                </mx:Component>
              </mx:itemRenderer>            
            </mx:AdvancedDataGridColumn>
          


          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          1 person found this helpful
          • 2. Re: checkbox in a Datagrid
            JockMahon Level 1

            Thanks for the reply, i tried your code.

            When i select the checkbox it does not show the tick

            i even tried

            data.FLAG =

            true;

             

            still nothing