0

I was given an AdvancedDataGrid and need helping adding a column of check boxes to the front. The code is something similar to this, though a good bit of the styling and extra functionality has been stripped out. Don't think an intern should be posting company code online.

<mx: AdvancedDataGrid>
    <mx:columns>
      <mx: AdvancedDataGridColumn dataField = "something1" headerText="1"/>
      <mx: AdvancedDataGridColumn dataField = "something2" headerText="2"/>
      <mx: AdvancedDataGridColumn dataField = "something3" headerText="3"/>
      <mx: AdvancedDataGridColumn dataField = "something4" headerText="4"/>
      <mx: AdvancedDataGridColumn dataField = "something5" headerText="5"/>
      <mx: AdvancedDataGridColumn dataField = "something6" headerText="6"/>
    </mx: columns>
</mx: AdvancedDataGrid>

I want to add a column of check boxes in front of the first column. Not entirely sure how to do it though. I found an example online(working on finding the link will post ASAP) that create classes that render the header(Need the header to function as select all and deselect all) and the check boxes, but no matter what I do it doesn't work. Anyone have any ideas or can point me to a good example of what to do. Anything with a detailed explanation would be greatly appreciated.

thad
  • 167
  • 1
  • 4
  • 16
  • 3
    Short answer: Use a custom itemRenderer. – JeffryHouser Jul 11 '13 at 02:21
  • I tried using that. But it wouldnt display. – thad Jul 11 '13 at 02:24
  • 2
    The problem is more with getting the custom itemRenderer to display. The checkbox part is additional to this. Look up and get an example of the custom itemRenderer working first, the checkBox part will be quite simple after that. – Drenai Jul 11 '13 at 07:22
  • Check this [Thread][1] [1]: http://stackoverflow.com/questions/1127387/adding-checkbox-inside-an-flex-advanced-datagrid I think it will help you – Arumugam Mathiazhagan Jul 11 '13 at 12:03

1 Answers1

0

In MXML section

<mx:DataGridColumn textAlign="center" width="25">
    <mx:headerRenderer>
        <fx:Component>
            <mx:CheckBox change="{outerDocument.fnChangeAll(chkAll)}" id="chkAll" selected="{data.flRead}" />
        </fx:Component>
    </mx:headerRenderer>
</mx:DataGridColumn>

In ActionScript code

public function fnChangeAll(chk:Object):void
{   
    var check:CheckBox= chk as CheckBox;
    for each (var curr:ObjectOfDataProvider in listObject) {
        curr.flRead=check.selected;
    }
}

(is the same thing with AdvancedDataGrid)

Summarizing: You must add an headerRenderer linked on your column, so you write a function about behaviour of your header.

Tell me if it's OK

Joe Taras
  • 15,166
  • 7
  • 42
  • 55