1 Reply Latest reply on Feb 27, 2007 1:53 PM by kiamber

    Datagrid with Checkboxes

    kiamber
      I think my issue is the Datagrid datafield has the same name for about 8 checkboxes. I then have selected equal to the name of the description that is being supplied my the database. My code is below:

      private function receiveSelections(event:ResultEvent):void {
      /upon receipt of results set the array collection to the result set received
      acDisplay = event.result as ArrayCollection;
      }

      Within my RemoteObject code I call the function:
      <mx:method name="getSearchAsQuery" result="receiveSelections(event)">

      Then for instance with just two checkboxes I have:
      <mx:DataGrid height="100%" dataProvider="{acDisplay}" id="dgDisplays" click="dgRowSelected()">
      <mx:columns>
      <mx:DataGridColumn headerText="Description1" width="60" dataField="Description">
      <mx:itemRenderer>
      <mx:Component>
      <mx:HBox horizontalAlign="center">
      <mx:CheckBox selected="{data.Description1}"/>
      </mx:HBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      <mx:DataGridColumn headerText="Description2" width="70" dataField="Description">
      <mx:itemRenderer>
      <mx:Component>
      <mx:HBox horizontalAlign="center">
      <mx:CheckBox selected="{data.Description2}"/>
      </mx:HBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>

      Any suggestions would be greatly appreciated! :0)
        • 1. Re: Datagrid with Checkboxes
          kiamber Level 1
          Well... just in case anyone else runs into the same kind of issue, I found the solution. Within my function:

          private function receiveSelections(event:ResultEvent):void {
          //upon receipt of results set the array collection to the result set received
          acDisplay = event.result as ArrayCollection;

          var i:int = 0;
          var obj:Object;

          //change the Description to properly select the associated checkbox
          for (i = 0; i < acDisplay.length; i++) {
          obj = acDisplay.getItemAt(i);
          if (obj.Description == 'Description1'){
          obj.Description1= 1;
          }
          if (obj.Description == 'Description2'){
          obj.Description2 = 1;
          }
          }


          Hope this helps!