You should be able to just set the property of the objects in your data 
provider that the checkboxes are rendering.  For example, if your grid 
is bound to an array of objects of type MyClass that are stored in 
mySourceArray:Array then this would do it.

private  function selectAll(selected:Boolean):void
{
   for each(var item:MyClass in mySourceArray)
   {
       item.selected = selected;
   }

   myGrid.invalidateList();
}

If you need to be very generic and do it for any grid... then you would 
need to do something like the following.  Note: the code below was 
created in this email and has not be compiled, etc.  But, it should get 
you close :)

private function selectAllInGrid(grid:DataGrid, selected:Boolean, 
selectedField:String):void
{
    var view:ICollectionView = ICollectionView(grid.dataProvider);
    var cursor:IViewCursor = view.createCursor();
    while(cursor.afterLast() == false)
    {
       var obj:Object = cursor.current;
       if(obj.hasOwnProperty(selectedField))
       {
          obj[selectedField] = selected;
       }
       else
       {
           trace("Items in the grid do not appear to have property " + 
selectedField);
       }     
    }
    grid.invalidateList();
}


hth
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com
http://blog.fastlanesw.com



p_repetti wrote:
> Hello
>
> I have created a DataGrid component whose last column is rendered/edited
> with a checkbox. This checks whether the row data will be sent to the server
> or not.
> Rather than forcing the user to check all of the rows manually, I have a
> "Select All" button which commands the selection of all the checkboxes in
> that column. 
> My problem is that I can't write the code to implement the selection. It is
> AS code most likely, but I could not find an example going through
> docs/forums/whatever.
> How do I loop over the DataGridColumn object to get the CheckBox instances ?
>
> Can anyone point me to useful examples/references ?
>
> Thanks
>   

Reply via email to