Hi
Thanks for your reply. Let me first tell you the situation actually what I am doing. I am retrieving the data(Images) from database and then displaying it in the table. From here I have given Administrator to move the selected data up or down so that it will display the modified data to the client side means to the user. Though I dont have any field in database for order no. I am swapping table row using javascript and then I am updating the modified table.
So there can be more than one swapping means I can swap row2 to row4 then I can swap row5 to row3 and row8 to row1 and so on... and then when I click the Update button it should update all the record(modified ) to the database. Or it should update the record as I swap the record one by one.
Thanks!
hi,
It sounds like you've done qite a bit of work on this already and the fact that you want to be able to move rows that are not next to each other at the start shouldn't matter.
However, without a rowOrder column in the table you are making lve unnecessarily difficult. If you do not have a row order then the table order must represent the displayed order which means moving lots of data arouind in a very complex fashion. With a rowOrder colum all you need to change is information in one column.
If you allow all the changes client side and then submit them to the server on the slick of a button then this is failry straightforward.
When the page loads in its original state you knwo the order numbers against each item, so keep these somewhere. Then as they are moved around you know the new order numbers. Simply run through a loop and change each number to the negative version of the new number. Once this loop is complete update the table once more changing all the negative numbers to absolutes.
I hope that makes sense, but I'm afraid that without the rowOrder column this problem is very tricky.
Cheers
nathj