2 Replies Latest reply on Feb 11, 2008 4:33 PM by ntsiii

    chechbox check all

    GeorgeWS Level 1
      I am having trouble checking all of the checkboxs in a datagrid. This is what I have:


      [Bindable] public var myChecks:Array;
      private function selectAll():void{
      myChecks.checked = true

      <mx:Button label="Check All" click="selectAll();"/>

      <mx:DataGrid id="myDataGrid" dataProvider="{myAccounts}" width="100%" height="100%" themeColor="#73B9B9">
      <mx:DataGridColumn headerText="Include" dataField="Include" width="58" sortable="false">

      <mx:HBox horizontalAlign="center">
      <mx:CheckBox id="myChecks" click="data.Include=!data.Include" selected="{data.Include}" themeColor="#73B9B9"/>


      I get this error:
      Cannot access a property or method of a null object reference

      Im thinking I can just have the selected attribute of the checkbox get set to true, all of the checkbox will be set to true? I probably will need to uncheck all also.


        • 1. Re: chechbox check all
          The reason I think you are getting that error is because you are declaring an Array called myChecks and then you are trying to access the "checked" value of it. And an Array does not have that value.

          So in your selectAll() function, you are accessing the Array and not the checkbox.

          Hope this helps you figure it out.

          • 2. Re: chechbox check all
            ntsiii Level 3
            You must control all itemRenderers through the dataProvider. George, you know this.

            Do a for-in loop over "myAccounts", set the .include=true on each item.

            Then either re-assign the data provider to the DG, or try calling itemUpdated() on the collection.