When there are no records in the grid to be dropped into, I have a "NoRecordsTemplate" and a drop occurs without any issues.
Is there a way to make this open area between the last record and the footer a "droppable" area? Do I have to display an image there of some sort (to mock the Recycle Bin functionality in the sample)? If so, how would I do that? Is there javascript somewhere that is cancelling this drop so that the AJAX RowDrop event is never firing?
Note, the drag/drop sample has the same issue.
Thanks!
17 Answers, 1 is accepted
The RowDrop event is fired every time a row is dropped in RadGrid, unless explicitly canceled as in the online example. A suggestion for you would be check for the destination element of the dropping row in the javascript RowDropping function, and fire the event if the destination element is the second RadGrid:
function onRowDropping(sender, args) |
{ |
var node = args.get_destinationHtmlElement(); |
if(!isChildOf('<%= RadGrid2.ClientID %>', node)) |
{ |
args.set_cancel(true); |
} |
} |
Then on the server, you can check if e.HtmlElement is the second RadGrid, and perform your custom row transfer:
protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e) |
{ |
if (!string.IsNullOrEmpty(e.HtmlElement) && e.HtmlElement == "RadGrid2") |
{ |
// Custom code here |
} |
} |
If your second RadGrid does not stretch down to the height of the first one (as in the online example), you can simulate this by nesting the grid inside another element with the needed width and height, and then performing the same operations as shown above.
Regards,
Veli
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

if (node.id == 'grdWhatever_GridData')
{
__doPostBack(
"<%= btnMoveTo.UniqueID %>", "Click");
}
These grids could have their items moved via drag/drop OR arrow buttons. So, when dropped into the "open area" (aka "Grd_GridData"), I manually do a postback simulating that the "Move To" button was clicked. This event has code that moves the selected item from one grid to the other.
Yes, this is another option implementing the row drag and drop functionality, where a certain destination html element triggers some custom action.
All the best,
Veli
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Is this possible?
My code is simple:
function onRowDropped(sender, args)
{
__doPostBack("<%= rdgCategoryBudget.UniqueID %>", "RowDrop")
}
Please advise.
Thanks


I thought about that and I have a couple of questions with this method.
On the source grid the you can select a row, but if you drag and drop a row without selecting it first the selectedindex is not set.
How do you determine which row they are dragging if they did not do a select of that row prior?
If they simply grab the row they want to drag and drop without selecting it first the selectedindex.count of the grid is always 0 so I can determine which row was selected.
Using the OnRowDropped I could always determine by useing DraggedItems.
How do you handle this.
Thanks
You cannot fire RowDrop server event in such manner. As it will require some arguments to be available in order to be fired correctly.
Best wishes,
Rosen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Alex-
You could do something like I'm doing probably. Here's the code:
Client Side (this seems to need to be in the actual aspx page instead of a separate js file for some reason):
function onRowDropping(sender, args)
{
if (sender.get_id() == "grdXXX")
{
var node = args.get_destinationHtmlElement();
//If the id is "grdAAA_GridData" then dropped into blank selected area
if (node.id == 'grdAAA_GridData')
{
document.getElementById('<%=hdnSelectedResourceIndex.ClientID %>').value = '';
__doPostBack("<%= btnMoveTo.UniqueID %>", "Click");
}
}
}
Button Click Event:
protected void btnMoveTo_Click(object sender, EventArgs e)
{
if (grdXXX.SelectedItems.Count > 0)
{
MoveResourceToSelected(int.Parse(grdXXX.SelectedValue.ToString()));
}
}
MoveResourceToSelected method:
This has code that moves the selected resource from the "available" to the "selected" list.
Hopefully this helps!

The first as I mentionned if the user grabs a row and drags it without physically selecting it the selectedindexes.count the grid is always 0 or better yet if he does select a row and drags another row instead the selectedindex(0) is that of the selected row and not the row that was drragged.
The second is not an issue but more of a question, this works when you drop it on the empty space of a grid. How do I prevent a double postback when I drop it on a destination row.
Double postback is caused by your code and the second postback caused by the OnRowDrop event of the grid because you did drop it on a valid area?
Thanks

About the second issue. Here's the complete js code (I only included a portion of it before):
function onRowDropping(sender, args)
{
if (sender.get_id() == "grdAvailable")
{
var node = args.get_destinationHtmlElement();
//If the id is "grdSelected_GridData" then dropped into blank selected area
if (node.id == 'grdSelected_GridData')
{
document.getElementById('<%=hdnSelectedResourceIndex.ClientID %>').value = '';
__doPostBack("<%= btnMoveTo.UniqueID %>", "Click");
}
if(!isChildOf('<%=grdSelected.ClientID %>', node) && !isChildOf('<%=grdAvailable.ClientID %>', node) )
{
args.set_cancel(true);
}
}
else if (sender.get_id() == "grdSelected")
{
var node = args.get_destinationHtmlElement();
if(!isChildOf('<%=grdAvailable.ClientID %>', node) && !isChildOf('<%=grdSelected.ClientID %>', node) )
{
args.set_cancel(true);
}
}
else
{
var node = args.get_destinationHtmlElement();
if(!isChildOf('trashCan', node))
{
args.set_cancel(true);
}
}
//Set hidden field (hdnDragInProgress) back to false
var hdnDragStatus = document.getElementById('<%=hdnDragInProgress.ClientID %>');
hdnDragStatus.value = "false";
}

I'm hoping a Teleriky (or is that a Telerikian) will explain why when you drag a row when you have a select column the selectedindex.count is 0 unless you specifically click on the select column first.
Not that is has that much impact, it's just bizarre.
I'm not sure I understand you correctly. You cannot drag a row without selecting it first. If you have multi-row selection enabled, you should first select row(s) and then you can drag them. Or if you have single-row selection the row is automatically selected when dragged.
Can you please provide (attached to a formal ticket) a sample demo in which this behavior can be reproduced? Thus I will do my best to advice you further.
Best regards,
Rosen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

I can most definitly drag/drop without first selecting the row(s), but then it really depends on your definition of selecting.
I can grap a row and drag/drop it without prior explicitly selecting it in this case the selectedindexes.count is 0, but the draggeditems object is correct (so I always use the draggeditems and ignore the selectedindexes).
Another scenario is if I select a row and then dragged another row, the selectedindexes(0) is not the same as the draggeditems(0). Again I always use the draggeditems object because it is alway right.
Feel free to submit the sample project once you assemble it. We will review it and will get around to you with our findings.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Puzzling!! It took me 2 hours to figure out why the event was not firing. If the grid is empty (no data), there is precious little real-estate to drop upon. It becomes quite possible that a user would drop upon the header.
In such case you can expand height of the no records item as shown in the second grid of the corresponding online demo of RadGrid for ASP.NET AJAX:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/draganddrop/defaultcs.aspx
You may also added a user-friendly message to clarify where grid records can be dropped to prevent the confusion.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
