1 Reply Latest reply on Oct 12, 2009 1:46 PM by timo888

    Alex's CheckBoxDataGrid  and select/deselect/iterate questions

    timo888

      I am using Alex's CheckBoxDataGrid. The first column, which contains the selection checkbox, is not data-bound; the other columns are bound to an ArrayCollection's items.  The databinding is working, as well as the select/deselect via mouse-click by the user on the check boxes. But I have some questions about how to select/deselect items programmatically.

       

      <myns:CheckBoxDataGrid id="HitsGrid" height="90%" width="100%" allowMultipleSelection="true" itemClick="onHitsGridRowClick(event);">
      <myns:columns>
      <mx:DataGridColumn headerText="show" editable="true" draggable="false"  sortable="false" itemRenderer="myns.CheckBoxRenderer"/>
          <mx:DataGridColumn headerText="short title" dataField="shorttitle" sortable="true"/>                        
         <mx:DataGridColumn headerText="title" dataField="title" sortable="true"/>
         <mx:DataGridColumn headerText="ttl" dataField="ttl" visible="false"/>
        </myns:columns>
      </myns:CheckBoxDataGrid>

       

      There are three associated buttons on my dialog too: SelectAll, SelectNone, ShowSelected.

       

      SelectAll's eventhandler needs to iterate through all the rows of the grid and select each row.

      SelectNone's eventhandler needs to iterate through the selected rows and deselect each.

      ShowSelected's eventhandler needs to iterate through the selected rows and display  the underlying data in the ArrayCollection in a TextArea.

       

      For the SelectNoneHandler, I tried iterating through selectedIndices or selectedItems and pop() -ing each index from the array, but that did not clear the checks from the checkboxes. I have also tried this:

       

       

       

      private function onSelectNoneClick(e:MouseEvent): void {
                  for each(var o:Object in HitsGrid.selectedItems) {
                      HitsGrid.isItemSelected(o)  = false;     // compiler error: 1105 "Target of assignment must be a reference value"
                 }
        }

       

      I don't know how to iterate all rows, or only the selected rows, and get a row handle so I can select|deselect the row.

      At this point, all I know how to do is iterate through the objects in the grid's data provider, an ArrayCollection.

       

       

       

      Thanks for the help.