tags:

views:

88

answers:

2
<local:CheckBoxDataGrid id="dg" 
        allowMultipleSelection="true"   x="118" y="151" width="557">
     <local:columns>
      <mx:DataGridColumn dataField="firstName" headerText="Select" width="50" sortable="false" itemRenderer="CheckBoxRenderer" > 
      </mx:DataGridColumn>
      <mx:DataGridColumn id="userID" headerText="User ID" />
      <mx:DataGridColumn dataField="userlevel" editable="true" headerText="Role" />
      <mx:DataGridColumn id="email" headerText="Email" />
     </local:columns>
    </local:CheckBoxDataGrid>

private function getUs(data:Object):void{
      var appSes:ArrayCollection = new ArrayCollection(data.result);
      dg.dataProvider = appSes;
      }

I am getting the values as ArrayCollection, but when i bind it to my Datagrid, i am not getting any values.... though the objects returned from PHP are fine.

+1  A: 

Have you tried debugging? I would suggest running a debug with a breakpoint immediately after setting var appSes, and inspecting that variable to be sure the ArrayCollection is being properly creating with e Service result data.

If the ArrayCollection is being created correctly, next make sure that the dataField names correctly match up with the data in the ArrayCollection - these are case-sensitive. Try removing all the columns from the DataGrid. If your ArrayCollection is valid, the DataGrid will automatically create columns with the dataField names in the ArrayCollection as the column headers:

ArrayCollection:
    {firstName: "Joe", userID: 1, userlevel: 3, email: "[email protected]"},
    {firstName: "Mary", userID: 2, userlevel: 4, email: "[email protected]"},
    {firstName: "Bob", userID: 3, userlevel: 2, email: "[email protected]"}

Will display as the following if you do not specify columns:

firstName           userId        userLevel    email
------------------- ------------- ------------ ----------------------------
Joe                 1             3            [email protected]
Mary                2             4            [email protected]
Bob                 3             2            [email protected]

Hope that helps!

Eric Belair
Thanks a lot....
No problem! Glad to help!
Eric Belair
A: 

My first recommendation would be to test this without loading things in through PHP. Copy the data to a local ArrayCollection and assign based off of that.

You also may want to initialize the dataprovider property (this sometimes helps, despite the fact that it is not supposed to):

<local:CheckBoxDataGrid id="dg" dataProvider="{ myArrayCollection }"

...

[Bindable]
private var myArrayCollection:ArrayCollection

...

private function getUs(data:Object):void
{
     myArrayCollection = new ArrayCollection(data.result);
     trace( myArrayCollection ); // Just a sanity check.

Let me know if that helps.

Christopher W. Allen-Poole