0
votes

Server is returning us the following JSON,

[{"id":"11111","progress":,"date":"Jan 14, 2013 12:00:00, "count":1,"status":0},
 {"id":"22222","progress":,"date":"Jan 15, 2013 12:00:00, "count":4,"status":1}]

so its returning an array. How do i map it to a flex datagrid.
i have tried this,

var jsonResult:Array = com.adobe.serialization.json.JSON.decode(e.result);
var dataArray:ArrayCollection = new ArrayCollection(jsonResult);  

So the dataProvider for the datagrid is {dataArray}. But if i provide the column's dataField as "id" or "progress", it does not show any data.
What is missing here, please let me know.

1
What's in your variables? Have you stepped through the code and watched the value of jsonResult? Also, I do not know com.adobe.serialization.json.JSON; it's not the native decoder.RIAstar
So how can i decode JSON at the Flex side?Blue Sky
Try var jsonResult:Array= JSON.parse(json)Alfonso Rubalcava

1 Answers

0
votes

This works well:

var arr:Array=(com.adobe.serialization.json.JSON.decode(event.result) as Array);
var dp:ArrayCollection=new ArrayCollection(arr);
flexDataGrid.dataProvider=dp;