calculateDropIndex should tell you where it is getting inserted, then you can 
get surrounding data and fix it up.

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Howard 
Fore
Sent: Thursday, September 18, 2008 6:34 PM
To: Flexcoders
Subject: [flexcoders] Using dragging in a data grid to update data in the 
dataprovider

Hey,

I've got a DataGrid fed from an ArrayCollection with drag and drop enabled. The 
data in the DataGrid is sorted on several different fields. What I'd like to do 
is to enable the user to rearrange the rows in the DataGrid via dragging and 
have part of the data update itself to how the user arranged the rows (so then 
I can write the data back to the database).

For instance:

rowOne    A    a    1
rowTwo    A    a    2
rowThree  A    a    3
rowFour   A    a    4
rowFive   A    b    1
rowSix    A    b    2
rowSeven  A    b    3
rowEight  A    b    4

If the user drags rowOne below rowThree, I'd like the underlying data to be 
rewritten to:

rowTwo    A    a    1
rowThree  A    a    2
rowOne    A    a    3
rowFour   A    a    4
rowFive   A    b    1
rowSix    A    b    2
rowSeven  A    b    3
rowEight  A    b    4

But if they were to drag it past rowFour it would look like:

rowTwo    A    a    1
rowThree  A    a    2
rowFour   A    a    3
rowOne    A    a    4
rowFive   A    b    1
rowSix    A    b    2
rowSeven  A    b    3
rowEight  A    b    4

I know some of this I can accomplish with the sort fields. But how do I get to 
the part where I rewrite the last field in the data based on the location of 
where the user drops the row? Can the function that gets called when the row is 
dropped see which rows are above and below it? Or am I better off dropping the 
last field from my sort, then loop over the data when the row is dropped, 
writing the row index to that column?

Any suggestions or shoves in the right direction are greatly appreciated.


--
Howard Fore, [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>
"The universe tends toward maximum irony. Don't push it." - Jeff Atwood

Reply via email to