This is a migrated thread and some comments may be shown as answers.

drag and drop - reorder rows

6 Answers 333 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Reid
Top achievements
Rank 1
John Reid asked on 04 Feb 2010, 03:12 PM
Hi -

I am looking for a simple example the will help me reorder rows by drag and drop in a grid.

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/draganddrop/defaultcs.aspx is far to complex for what I an trying to accomplish.

I have a simple grid with a "sortorder column". I would like to be able to drag the rows (keeping them inside the grid) to move them the to different levels on the grid changing the order. A button it would save the take the new sort from the grid and then i could save the new row order and update my table. 


Is there any examples? I am looking for simple drag and drop row sorting and saving?



6 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 05 Feb 2010, 09:03 AM
Hello John,

Attached is a small sample demonstrating drag-and-drop on a single grid. Please, note that the example cannot get simpler as the drag-and-drop scenario is not the most simple one.

I hope this helps.

Regards,
Tsvetoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Dip
Top achievements
Rank 1
answered on 15 Feb 2010, 09:27 PM
How can I make the change permanent in the database? I want the client to see it the way I arranged it.
0
Tsvetoslav
Telerik team
answered on 17 Feb 2010, 04:14 PM
Hi Dip,

The records in the database are not kept in a sorted order - they are just stored there. The order in which you retrieve them and afterwards bind them to the grid is what matters. Having this in mind, to achieve the scenario, in question, is not such an easy task. One approach I'd suggest is to add an extra field to your database table to reflect the order of the records in which they should be displayed in the grid, let's say OrderIndex. When retrieving the records you should sort them (with the OrderBy clause by this field). Afterwards, upon each rearrangement with a drag-and-drop operation you need to update (through database operations) the OrderIndex of the record being dropped and adjust the OrderIndex of all the records after its new position. That should be done in the grdPendingOrders_RowDrop where you can easily extract all the information necessary for the database queries.

I hope this information will prove helpful.

All the best,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
momentum
Top achievements
Rank 1
answered on 12 May 2010, 12:17 AM
Hi, can i get a copy of this simple example in VB?

I already have a working application with a grid tied to a db table (row order is controlled by an orderNUM column in the table). I already have it re-ordering but with the click of a button - if you click to move an item up, I swap the "above" orderNUM with the "current" orderNUM in the db then rebind the data (same for moving an item down). My approach will be very similar except I won't be swapping the orderNum's, instead I need to get the orderNUM of the row above and below the newly 'dropped' item and adjust the orderNUM of the dropped row and all subsequent rows. I am just not sure how to figure out (server side) which row is being dropped and how to access the rowdata of the row above/below the dropped item. Any help would be appreciated.

Thanks
0
Tsvetoslav
Telerik team
answered on 14 May 2010, 10:14 AM
Hi Brian,

Attached is the sample with a VB page added.

Sincerely yours,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Norway77
Top achievements
Rank 1
answered on 24 Feb 2015, 01:05 AM
Hi,
Is it possible to get the c# code for the current version of Telerik and VB 2013.
I can't seem to get the old one working.

I'm looking for the exact same functionality.  Just to move a row up or down in a radgid and then update the database with the new position.
thanks
Tags
Grid
Asked by
John Reid
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Dip
Top achievements
Rank 1
momentum
Top achievements
Rank 1
Norway77
Top achievements
Rank 1
Share this question
or