views:

19

answers:

1

I am trying to use JSON decoded as a dataProvider, but no matter what I try I get errors such as the following:

Error #1034: Type Coercion failed: cannot convert    
mx.collections::ArrayCollection@2a88ae01 to fl.data.DataProvider.

I am only returning a simple JSON object array of 3 elements with 3 properties each.

I am currently doing the following:

  var arr:Array = (JSON.decode(rawData) as Array);

  var dp:ArrayCollection = new ArrayCollection(arr);

  grid.dataProvider = dp;

EDIT - MORE INFO

If I change the last line of the above code to

      grid.dataProvider = new DataProvider(dp);

I get the following error

    TypeError: Error: Type Coercion failed: 
    cannot convert [object Object],[object Object] to Array or DataProvider.
+1  A: 

What changing the last line to this?

grid.dataProvider = new DataProvider(arr);
Ryan Lynch
This did not work... see the edit to my original post.
Dve
I see the edit, but it looks like you are trying to cast the array collection dp to a DataProvider and not the array arr
Ryan Lynch
Appologies.. I have tried what youy suggested.... and it works!! Typically the only thing I hadnt tried! Many Thanks Ryan
Dve
Glad I could help.
Ryan Lynch