开发者

Problem converting Array to Arraylist for dataProvider

private var MealsListResult:ArrayList = new ArrayList;
protected var _data:resultData = new resultData;

private function resultHandler():void
    {   
    var Meals:Array = _data.Meals;
    MealsListResult = _data.Meals as ArrayList;
    MealDataGrid.dataProvider = Meals;
    MealListView.dataProvider = MealsListResult;
    }

Should this be working? the MealDataGrid is populating based on the array, but I am debugging and MealsListResult is null. but _data.Meals is not and I dunno if I'm missing something simple.

I can get it to work by doing it like: var MealsListResult2:ArrayList = new ArrayList(Meals); but I feel as though th开发者_如何学Ce first method should be working as well!

(there's mxml list and datagrid and such not shown here of course)


if _data.Meals is its runtime type is an array then _data.Meals as ArrayCollection will failed. but, new ArrayCollection(_data.Meals as Array) will working fine.

CMIIW i guess your problem is you can't use single object as 2 or more different ui dataprovider.

try to use

MealDataGrid.dataProvider = _data.Meals;
MealListView.dataProvider = ObjectUtils.clone(_data.Meals);

UPDATE:

sorry i miss readed, i though it was ArrayColletion. but all you need to do is the same like ArrayCollection

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜