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

Data Grid rows reorder using drag and drop

9 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
loai taha
Top achievements
Rank 1
loai taha asked on 10 Mar 2010, 02:27 PM
Hi,

I need to know how to make it possible to reorder the rows in a single rad data grid using grid drag and drop functionality.

I went through live examples as well as few posts in here, yet, couldn't find the solution. all what I'm looking for is to allow users to drag and drop rows to perform reordering and to show the new ordering as well.

It's highly appreciated if you can provide code sample that demonstrate the above scenario, and please don't ask me to view live examples because I already did and couldn't find the solution!

Thanks for your help and assistance in advance :-)

Regards,

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Mar 2010, 04:04 PM
Hi,

You've missed this example:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/draganddrop/defaultcs.aspx

Sincerely yours,
Vlad
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
loai taha
Top achievements
Rank 1
answered on 10 Mar 2010, 05:23 PM
Dear Vlad,

Thanks for your fast response, however, I went through that example as well as the rest of all live examples, and that is why I needed a simple sample code, because of the complexity of the life examples.

The scenario that I'm looking for is much simpler than that live example.

Regards,
0
Yavor
Telerik team
answered on 15 Mar 2010, 08:28 AM
Hi loai,

For additional information on the logic behind this example, you can review the description tag. It contains all the related information on the events which are raised when dragging a row. Once you acquaint yourself with the events regarding this logic, you can handle the setup as per your requirements - if you are using a different datasource, or want to cache the data, or anything else. Regardless of these differences, the core logic/events remain the same. The client side events allow you to handle logic prior to persisting the change in the database - identify the row/target element, or cancel out the event.
The server side event allows you to handle the actual persistence of the item in the database.
I hope this information helps.

Sincerely yours,
Yavor
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
loai taha
Top achievements
Rank 1
answered on 30 Mar 2010, 01:44 PM
Dear Yavor,

it's very obvious that you got me totally wrong. I know exactly when and how to use client side events.

What I really need was a sample code that is much simpler than what you have on the live demo section, that can be applied to a single grid with a straight forward scenario (ordering rows using drag and drop only) and not an explaination about when to use client and server sides events.

Regards,
0
Yavor
Telerik team
answered on 31 Mar 2010, 09:23 AM
Hi loai,

The example cannot actually get much more simple. It consists of two main logical parts. The first are the clientside/server side events, which are fired and facilitate the detection of the user actions. These cannot be reduced/avoided. The other part is the actual persistence of the data in the underlying database. While this can vary from setup to setup, the logic remains the same. Can you let me know which part of the logic/code is unclear, or hard to replicate at your end.

Sincerely yours,
Yavor
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
loai taha
Top achievements
Rank 1
answered on 31 Mar 2010, 10:25 AM
Hi Yavor,

Thanks for the fast response. If you really wish to help, then please tell me if it is possible to reorder rows of RadGrid control on the client side only without persisting data in the underlying database. On the other hand, if it is possible to be done then would the re-ordered row shows in the new place at the client side without the need for a postback! i mean would rows shift up or down to accommodate the new order!

Regards,
0
Yavor
Telerik team
answered on 01 Apr 2010, 09:41 AM
Hi loai,

Handling this setup without persisting the data to some sort of data source/medium cannot be achieved. The reason for this is that when the control is refreshed, the changes will be wiped out. Since the control does not support an unbound data mode, you will need to propagate the changes to the datasource. In most cases, this is not an expensive operation, so it will have little impact on the performance.

All the best,
Yavor
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
loai taha
Top achievements
Rank 1
answered on 01 Apr 2010, 10:57 AM
Thanks Yavor,

This approach surely will have a great impact on performance. Let's say you have 10 rows, and for the worst case scenario, user might change the order of all the 10 rows, at that case 9-10 postbacks might be needed to perform the full ordering!... I think the best way to order a grid would be by binding its rows main field to a list box with ordering buttons enabled, upon the finish of ordering the user submits the new order and the datagrip should be updated accordingly. Tell me what you think about this approach!

Regards :-)
0
Yavor
Telerik team
answered on 06 Apr 2010, 02:07 PM
Hello loai taha,

Indeed, the approach would have a better performance. However, at present the control does not expose any easy way to handle the functionality in such a manner. Additionally, there is no easy way to track the different states of a row. This is the reason the control exposes the present sets of events - so that each row (set of rows) is reordered immediately, and the state of the grid is refreshed, to reflect the changes.

Sincerely yours,
Yavor
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.
Tags
Grid
Asked by
loai taha
Top achievements
Rank 1
Answers by
Vlad
Telerik team
loai taha
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or