[FB4] Spark List bug and workaround with XML and drag features
Hello,
I thought I would post this to help out anyone else having trouble with drag enabled spark lists which are bound to XML data via XMLListCollections.
If you setup 2 lists with drag enabled features using XML data, you will find that what you see onscreen and what the data is doing are different. It appears that the drag operation works fine, you see the item moved from 1 list to another, however the xml node data for that item doesn't move to the new list.
Good news is I have created a workaround and added the drag enabled support. The key to the success of my workaround is when the item is dropped and data node is appended to the dataprovider of the target list, calling copy() on the xml node in the draginitiator resolves the issue. Apparently the addItem in the drop and the removeItem in the dragComplete event conflict with each other causing the error.
Attached is my code with examples of my workaround and the List error. The attachment is a .fxp file but I had to zip it to upload. Just unzip and use File-> import -> flex project to get it running. You must have Flash Builder 4 or Flex 3 with 4.0 SDK or higher running.
I have implemented manual support for Drag and Drop. The custom item renderer starts the drag and performs cleanup - see code in the item renderer. Remaining functions are in the main application file.
I tried to leave it as simple and sweet as possible. If you find it useful and build more support into it, please post your code in this thread for others as well.
Thanks!
Last edited by Gohloum; 07-01-2010 at 09:54 AM.
The Early Bird may get the worm, but the second mouse to the trap gets the cheese...