4 Replies Latest reply on May 24, 2009 10:44 PM by Mohd Fayaz

    Getting itemRenderer value in DataGrid

    Mohd Fayaz Level 1

      I have a DataGrid with CheckBox as ItemRendere in one of the column. My requirement is to retrieve all the rows in DataGrid whose checkboxes have been selected. I am using Cursor to accomplish this. But, I dont know how to retrieve the checkbox selected value in cursor. When I debug my application, cursor is reading all the coumn values in DataGrid except the CheckBox column.

       

      Can anyone please tell me how to read the checkbox value. It is urget.

        • 1. Re: Getting itemRenderer value in DataGrid
          Mohd Fayaz Level 1

          Here is a sample code I am using

           

           

                       var processList:Array = new Array();
                       processList.length = 0;                                                    
                       var myCursor:IViewCursor = dgFilter.dataProvider.createCursor();

                        while(!myCursor.afterLast){                                        
                           if(myCursor.current.select == true)
                               processList.push(myCursor.current.process);                                 
                           myCursor.moveNext();
                       }

           

           

           

           

              <mx:DataGrid id="dgFilter" width="100%" height="100%">
                  <mx:columns>
                            <mx:DataGridColumn width="20" dataField="select" headerText=""
                          editable="true"
                          rendererIsEditor="true"
                          itemRenderer="mx.controls.CheckBox"
                          editorDataField="selected"/>
                     
                      <mx:DataGridColumn headerText="PID" dataField="pid" width="50" textAlign="center"/>
                      <mx:DataGridColumn headerText="Process" dataField="process" textAlign="center"/>
                      <mx:DataGridColumn headerText="Name" dataField="name"/>
                  </mx:columns>
              </mx:DataGrid>

          • 2. Re: Getting itemRenderer value in DataGrid
            Michael Borbor Level 4

            itemRenderers are recycled, in your case I'll add an extra field or property to your dataProvider and set that value to true or false if a user checks or unchecks the CheckBox using itemEditEnd.

            1 person found this helpful
            • 3. Re: Getting itemRenderer value in DataGrid
              Flex harUI Adobe Employee

              There is an example on my blog where the checkbox updates the set of selectedItems.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: Getting itemRenderer value in DataGrid
                Mohd Fayaz Level 1

                @Flex harUI

                 

                 

                Thanks for your reply.

                However, I need some more help on your CheckBoxDataGrid. I need to add "invert selection" functionality in the DataGrid i.e. when I click a button "invert" it should unselect all the selected checkboxes and select all the unselected check boxes.

                 

                I look forward for your help.