PDA

View Full Version : dd and saving row order in one grid



cs01rsw
10 Sep 2010, 11:48 AM
Hi,

We have a grid of approx 1000 rows. the users want to be able to drag and drop the items into a specific order. Is there a way you guys would save this in the database with as little code as possible.

we thought of having an integer column to store the order value (1,2,3,4,5,etc...), however the code for this would get quite complex and slow as if they drag item 1000 to item 2, as we will have to move every item from 2 to 1000 down by 1 before inserting the new row into slot 2.

if we was to do it this way then we also couldnt allow them to do multi-select drag and drop as by the time we insert the first item all other items ready to be moved could have had their index's changed already.

thanks for your help

13 Sep 2010, 4:31 AM
Hi,

We have a grid of approx 1000 rows. the users want to be able to drag and drop the items into a specific order. Is there a way you guys would save this in the database with as little code as possible.

we thought of having an integer column to store the order value (1,2,3,4,5,etc...), however the code for this would get quite complex and slow as if they drag item 1000 to item 2, as we will have to move every item from 2 to 1000 down by 1 before inserting the new row into slot 2.

if we was to do it this way then we also couldnt allow them to do multi-select drag and drop as by the time we insert the first item all other items ready to be moved could have had their index's changed already.

thanks for your help

You might consider an "index" column for your database records. You should be able to do multi-select drag and drop.

In essence, your front-end should return a list of ids in an array. Their inherent index could be detected by the back-end and saved in the database as such.

cs01rsw
18 Sep 2010, 8:17 AM
thanks for the reply.

is the ordering via index possible using MySQL, as i know many of the indexs are not available?

could you also provide an example as i dont understand how to implement your idea

thanks