tags:

views:

754

answers:

1

I am getting return type as array from PHP. When i populate in my datagrid, the values are not coming... i dont construe why it is happening like this.

var appSes:Array = event.result as Array
dg.dataProvider = appSes;

I am getting the values, from PHP is there anything other than this i have to do.

<local:CheckBoxDataGrid id="dg" 
        allowMultipleSelection="true"   x="118" y="142" width="507">
     <local:columns>
      <mx:DataGridColumn dataField="firstName" headerText=" " width="20" sortable="false" itemRenderer="CheckBoxRenderer" > 
      </mx:DataGridColumn>
      <mx:DataGridColumn dataField="firstName" headerText="First Name" />
      <mx:DataGridColumn dataField="lastName" headerText="Last Name" />
     </local:columns>
    </local:CheckBoxDataGrid>
A: 

Use an ArrayCollection not an Array. In general, you should always use ArrayCollections when binding to dataProviders of Lists, Grids, etc since they are property-change aware and will inform the List whenever objects are added, removed or changed within them. Arrays do not provide this behavior.

Change your var to this

var appSes:ArrayCollection = new ArrayCollection(event.result);
dg.dataProvider = appSes;

I tend to bind my views to the model objects rather than explicitly setting them like you are. Has the benefit that if I create a new instance of the ArrayCollection (say, when refreshing data from the server), things correctly update without any additional effort on my part.

Thus, I would do:

<local:CheckBoxDataGrid id="dg" dataProvider="{appSes}" ....
verveguy