I guess I'm just not getting it.  The datagrid (id=dg2) has a dataProvider.  
Each column in the grid is associated with one element in the dataProvider 
except for the renderer where the checkbox is.  That is in a renderer because 
based on other fields it will be either enabled or not.

After a button is pressed, a routine is invoked that will loop through the 
dataProvider source to see if the checkbox were clicked.  What I don't see is 
how to connect the renderer to the dataProvider checkbox field.  Any reference 
to it causes a "can't do that to a null object" message.

I added another field to the VO and in the renderer I can  change the value of 
a Boolean such that it is true if the box were checked.  This was done by 
adding a "change" event to the renderer.  Since I could change the value of the 
field I don't see why I couldn't change the value of the checkbox field.

From: [email protected] [mailto:[email protected]] On Behalf 
Of Alex Harui
Sent: Friday, December 07, 2012 1:29 AM
To: [email protected]
Subject: Re: [flexcoders] Checkbox in grid



Usually the checkbox changes something, either in the selection model or the 
data model, and you loop over that model.


On 12/6/12 7:58 AM, "Davidson, Jerry" <[email protected]> wrote:





I have a check box in an advancedatagrid along with other fields.  They all 
show up as does the checkbox.  I can check the box(es).  There is a button that 
will then process the selected records.

I start a loop on the grid, but I don't know where to go from there.  The two 
things I want to do is 1) if the row is checked, add it to an array for further 
processing and 2) when coming into the array clear any checks still in there 
from the last time.

The user will click on array1 and the data is used to populate array2 with 
details.  Array2 also has the checkbox in an itemrenderer and below it a 
process button.  You click the records you want processed then the button to 
build an array of selected records that are passed on for further processing.

The array code looks like this:
    <cust:MyAdvancedDataGrid
            id="dg2"
            resizableColumns="true"
            height="100%" width="100%"
            editable="false"
            styleName="mainGrid"
            dataProvider="{model.userAARetrieveList}"
            headerStyleName="datagridHeaderStyles"
            selectionMode="singleCell"
            accessibilityName="A and A Report History List, DataGrid, use arrow 
keys to navigate between cells">
           <cust:columns>
                 <mx:AdvancedDataGridColumn
                        id="select"
                        headerText="Select"
                        
itemRenderer="gov.il.dhs.wvs.view.renderers.UserAA_Chck_Renderer"
                        width="45"/>

                 <mx:AdvancedDataGridColumn
                        headerText="Week Ending"
                        
itemRenderer="gov.il.dhs.wvs.view.renderers.UserAA_WE_Renderer"
                        width="85"/>
more columns...

The processing button code looks like this:
    // bottom grid clicked
    var dg2AC:ArrayCollection = new ArrayCollection();

     for each (var obj:Object in dg2.dataProvider)
      {
           if (obj.select.selected)
            {
                  dg2AC.addItem(obj);
            }
      }

     if (dg2AC.length == 0)
           return;

      (new UserAAInsertEvent(dg2AC as UserAAInsertVO)).dispatch();

I've spent the last hour reviewing blogs and such, but can't seem to find the 
right stuff.





--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui

Reply via email to