开发者

Flex: Swapping two elements in Array Collection

开发者 https://www.devze.com 2023-02-28 12:42 出处:网络
What\'s the best-approach to swap to elements in a Flex Array Collection? I am binding a ArrayCollection as a dataprovider to combo-box.

What's the best-approach to swap to elements in a Flex Array Collection?

I am binding a ArrayCollection as a dataprovider to combo-box. Selecting a row, should move the object to the top of the combo-box list, 开发者_Python百科and move the top-object to selected object's position.


I would do this instead:

dataProvider.addItemAt(dataProvider.removeItemAt(selectedIndex), 0);

The only problem is that this would make the combobox rebind twice, but for simplicity sake it shouldn't be an issue.


Tried setItemAt?


This worked!

      var temp:Object = myDataProvider.getItemAt(0);
      var pos:int = myDataProvider.getItemIndex(selected);

      myDataProvider.setItemAt(selected,0);
      myDataProvider.setItemAt(temp,pos);
      myDataProvider.refresh();
0

精彩评论

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