Flex - Saving a new order of items of a HorizontalList through AMF
I've been working with the drag-and-drop of items inside an Horizontal List in Flex. It works fine, but now I need to save the new order through AMF in my database. I'm pretty sure it's quite easy, but I haven't figured it out yet.
Is there a way to cycle (after the reordering) all the items so that I can get for each item its (new) index?
And I noticed that even if I change the order, the order in the dataProvider is always the same...
This is my list:
<mx:HorizontalList id="horizontalList"
allowMultipleSelection="true"
allowDragSelection="true"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
labelField="lbl"
iconField="src"
itemRenderer="CustomItemRenderer_gallery"
columnCount="5"
columnWidth="125"
rowHeight="125"
horizontalScrollPolicy="on"
doubleClickEnabled="true"
click="{click(event);}"
drag开发者_Go百科Drop="handleBtnReorder(event)"
doubleClick="doubleClick(event);" />
I would just loop through the Lists dataProvider that you dragged the items onto... while looping store the new order (i) in a variable in your ArrayCollection populating the dataProvider... then convert the ArrayCollection to an array to be passed to your server side for processing.
something like:
for(var i:int = 0; i < yourList.dataprovider.length; i++)
{
yourList.dataProvider.getItemAt(i).order = i;
}
// then convert the ArrayCollection to an Array and pass to your RemoteObject.
精彩评论