PDA

View Full Version : DataGrid column from JSON nested array


beevee@mac.com
01-09-2009, 03:20 PM
From searching around I gather that labelFunction is what I need in order to make the fields within a nested array visible in my DataGrid but so far implementation of labelFunction seems to be a state secret.

Currently I'm doing this:

private function sentimentRH(event:ResultEvent):void {
var data:Object = JSON.decode(event.result.toString());
dataList = new ArrayCollection(data.features); }

The data is there, I can see it in debug but dataField doesn't understand "nestedarray.field". The top level array (data.features) has only one field I need for the DG, but the nested array (products) has the field data I need for the rest of the DG, 4 other columns.

Anyone?

MattJohnson
01-09-2009, 10:27 PM
try adding the property
dataField="MyFieldName"
to the dataGrid

( I think its labelField="MyFieldName" for comboboxes in case you need it)

beevee@mac.com
01-09-2009, 11:22 PM
I found a great solution from Nate Ross - his extension of DataGrid called NestedDataGrid which works awesome. You can find it here:

http://natescodevault.com/?p=61

Works just like DataGrid but now dataField understands nested objects and arrays.

Thanks, Nate, wherever you are!!