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

[Solved] DragDrop in Hierarchichal RadGrid => e.DestDataItem is null when dropping on row header / "No records to display" message

1 Answer 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chrbra
Top achievements
Rank 1
chrbra asked on 28 May 2013, 11:29 AM
Hi,

I've got a hierarchichal RadGrid with one Detail Table. Lets call the items on the upper level "boxes" and the ones in the detail table "apples" - which is quite near reality in this case. (only we're not actually tracking apples ;-))

The user can move one or more different apples from one to another box via DragDrop.

This works fine when the apples are dropped on a specific box: Then I get a e.DestDataItem from the RadGrid1_RowDrop(object sender, GridDragDropEventArgs e) event, and I can figure out which box the apple(s) were placed in.

It also works fine, when there are already apples in a box, and some other apples are dropped on these rows. Then again I get a e.DestDataItem, and I can figure out, which box these apples are in, and I can add the dragged apples to the same box.

BUT: If apples are dropped either on the header rows of the DetailTable, or if a box is empty and they are dropped on the "No child records to display", then the e.DestDataItem is null. This sort of makes sense, but in this case I need a reference to the box, so I can add the dragged apples to this box.
I spent almost an hour now inspecting the GridDragDropEventArgs I get in this case, and I can nowhere find a reference. As soon as the DestDataItem is null, there seems to be no way of finding out which box the apples were dragged on.

The DestinationGrid and DestinationTableView Members are both not-null, so maybe I am missing something.
Any help is appreciated.

Best,
Christian

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 31 May 2013, 04:13 PM
Hello Christian,

When dropping over a table view which does not contain records it is expected the e.DestDataItem to be null In this case I suggest that you use the e.DestinationTableView instead as it returns a reference to the GridTableView over which the drop has occurred.(in the particular case the table view which has no records). As for dropping a record on a header row I suggest that you obtain a reference on the client to the GridTableView which holds this header. This can be achieved using the code snippet below:
function onRowDropping(sender, args) {
           var GridTableView = Telerik.Web.UI.Grid.GetFirstParentByTagName(args.get_destinationHtmlElement(), "table");
           var tableView = $find(GridTableView.id);
       }

Note that when a row is dropped over the header the server-side OnRowDrop will not fire. That said the adding/removing of items should be done client-side.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
chrbra
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or