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

Drag and Drop - OnRowDrop not called

2 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 09 May 2013, 02:29 PM
I have read the documentation on this multiple times and I can't see where I am going wrong.  I have a grid which displays a single column for a list of personnel and another grid which lists events which the user is attending.  My intention was to allow the user to be added to the event simply by dragging the person from the first grid to the second.

Both grids are mapped to ObjectDataSources - although the data sources are different for each.  I get the client side OnRowDropping event fired which I handle client side and ask the user to confirm.  I have checked that this does not change the args.set_cancel however the server side OnRowDrop event is not called.  I have seen this come up before but there is no fix detailed.  

Initially I was using Ajax but I have removed all of that to try a simple postback approach but no change.  Are there additional rules that I must follow to be able to drag from one grid to another where the grids are displaying different information?

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 09 May 2013, 10:26 PM
Having worked through another example I think that the issue with drag and drop may be caused by me not specifying anything for the 'DataKeyNames' grid attribute.  My problem is that I am creating the columns dynamically on the server side as I read data from the database.  This is done in Page_Load.  I first add a number of GridBoundColumn's to the grid and then manually add the data.  I have added a column and set its 'UniqueName' to 'ID' and then set the following...

GridBoundColumn personnelColumn = new GridBoundColumn();
grdPendingOrders.MasterTableView.Columns.Add(personnelColumn);
personnelColumn.HeaderText = "ID";
personnelColumn.DataField = "ID";
personnelColumn.UniqueName = "ID";

...
grdPendingOrders.DataSource = _eventsTable;
grdPendingOrders.MasterTableView.DataKeyNames = new string[] { "ID" };

Trouble is I now get an error saying that 'ID' is not a DataColumn or Relation which as far as I can tell it should be a column.  Please help as I am at a loss now what to do next.


0
Marin
Telerik team
answered on 14 May 2013, 10:33 AM
Hello,

 When you add the columns to the grid dynamically basically there are two recommended approaches. If your grid is already defined in the markup and you just add the columns in code-behind you should follow the code sample show here:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section1

If you create the entire grid and columns dynamically in code-behind you can follow the approach shown here:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section22

Both code sample also show how to set DataKeyNames properly so that no error is thrown.

I hope this helps.

All the best,
Marin
the Telerik team
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
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Marin
Telerik team
Share this question
or