Posted
on Mar 26, 2009
(permalink)
Is it possible to drag one or more rows from one radgrid to another radgrid on a form?
I saw there was a property allowdrop so i'm guessing that it is possible.
Is there some example code on how to do this?
thanks
Reply
Answer
Jack
Jack
Posted
on Mar 30, 2009
(permalink)
Hello gerbrand,
Thank you for this question.
Currently
RadGridView doesn't support this operation directly. We will consider adding this feature in one of our upcoming releases. However, you could achieve the same effect with a few lines of code. You should handle the
MouseDown,
MouseMove and
MouseUp events.
Please consider the code snippet below:
You should also inherit
RadGridView and process it's
OnMouseDown event if you want to drag & drop multiple rows:
I hope this helps. Don't hesitate to contact us if you need further assistance.
All the best,
Jack
the Telerik team
Check out
Telerik Trainer
, the state of the art learning tool for Telerik products.
Reply
Posted
on Apr 6, 2009
(permalink)
This works very good, but I'm wondering if I drop a row on the parent of the second grid, I want the dragged rows to be added to the childtemplate of that parent.
I think I need to work with the location of the mouse in order to find the parent?
Reply
Jack
Jack
Posted
on Apr 6, 2009
(permalink)
Hi Gerbrand,
Yes, you should use the
GetElementAtPoint method to get the currently hovered cell. Then use its
ViewTemplate property to get the corresponding child view template. I will be able to give a more concrete suggestions if you send us the source code for your project.
If you need further assistance, I will be glad to help.
All the best,
Jack
the Telerik team
Check out
Telerik Trainer
, the state of the art learning tool for Telerik products.
Reply
Posted
on Apr 6, 2009
(permalink)
Hmm, I didn't see any method called getElementAtPoint for the radgridview? That was the first thing that I looked up. But I found the getChildAtPoint, but that returns a control. Not the thing I need.
I used the code you posted as answer in my first question.
So I'm kind of stuck at that point...
Reply
Jack
Jack
Posted
on Apr 6, 2009
(permalink)
Hello Gerbrand,
GetElementAtPoint is accessible through the
ElementTree property. I used this method in the sample from my previous post. Please consider the code snippet below:
Don't hesitate to write us if you have any other questions.
Best wishes,
Jack
the Telerik team
Check out
Telerik Trainer
, the state of the art learning tool for Telerik products.
Reply
Posted
on Apr 7, 2009
(permalink)
Hi Jack,
I tried this: "var element = rgvAdlPositions.ElementTree.GetElementAtPoint(e.Location);" but every time is element "null".
My second grid has elements so that isn't the problem.
a quick code snippet:
Thanks
Reply
Jack
Jack
Posted
on Apr 7, 2009
(permalink)
Hello Gerbrand,
I forgot to mention that when handling the
MouseUp event of the first
RadGridView, the coordinates are relative to this control. You should translate them. Here is a sample:
Should you have any further questions, I will be glad to help.
All the best,
Jack
the Telerik team
Check out
Telerik Trainer
, the state of the art learning tool for Telerik products.
Reply
Posted
on Apr 7, 2009
(permalink)
Hmm,
It doesn't work. I still get a null for the element. Maybe I'm doing something wrong?
Thanks in advanced
Reply
Jack
Jack
Posted
on Apr 8, 2009
(permalink)
Hi Gerbrand,
The problem is that the point
"pt" is already transformed in coordinates relative to your
Form. This is made in the first call to the
PointToClient method (this is the
6th line in your code). The
PointToClient method requires screen coordinates, so when you are converting the point again, you get the wrong coordinates. I modified
rgvAdserver_MouseUp event this way:
It should be working now. If you have further questions, I will be glad to help.
Best wishes,
Jack
the Telerik team
Check out
Telerik Trainer
, the state of the art learning tool for Telerik products.
Reply
Posted
on Apr 8, 2009
(permalink)
Excellent...
works nice...
Thanks a lot Jack.
Reply
Posted
on Apr 29, 2009
(permalink)
How can I make it visual the drag drop?
If I drag row(s) to the other radgrid you don't really see if the dragdrop is happening. Just the cursor that turns into a hand.
Can I make it visually the drag to the other gridview? that the selected row is half visible hanging to the mousepointer?
If you understand want I mean :-)
thanks
Reply
Jack
Jack
Posted
on Apr 30, 2009
(permalink)
Hi Gerbrand,
You can achieve this by using an outline
Form that shows a snapshot of the rows. You should move the form when the mouse changes its coordinates. The
TelerikHelper.CreateOutlineForm method can help in this situation. Please check the modified code below:
And here is the
GetBitmap method used to create the snapshot:
I hope this helps. If you need further assistance, feel free to write me.
Regards,
Jack
the Telerik team
Reply
Posted
on Apr 30, 2009
(permalink)
Thanks Jack,
Just one small thing. Have a look at the
screenshot I took.
The bitmap stays still on that position as long as I am dragging.
The bitmat isn't at the pointer but at the top of my main form the first time. Second time is goes a little bit lower and so on.
Hope you have a solution?
Reply
Jack
Jack
Posted
on Apr 30, 2009
(permalink)
Hi Gerbrand,
Maybe there is a problem with the coordinates. You should use screen coordinates when setting the
Location property. It shouldn't be a problem if you use exactly the code from my post. You can also send me your application [in a support ticket] and I will be able to give more concrete suggestions.
I am looking forward to your reply.
Greetings,
Jack
the Telerik team
Reply
Posted
on Apr 30, 2009
(permalink)
Argh... I found the problem ... stupid of me..
I forgot the else part in the mousemove event
else if (dragging)
{
var mousePt = MousePosition;
outlineForm.Location = new Point(mousePt.X + 5, mousePt.Y + 5);
}
Now it works nice :-)
Thanks Jack
Reply
Jack
Jack
Posted
on Apr 30, 2009
(permalink)
I am glad to hear that you have found the issue. If you have any other questions, don't hesitate to write me.
Sincerely yours,
Jack
the Telerik team
Reply
Saravanan
Posted
on Mar 15, 2010
(permalink)
the event MouseDown,MouseMove Did not get fired what might be wrong with Me?
Reply
Posted
on Mar 16, 2010
(permalink)
Can you post some code?
Reply
Jack
Jack
Posted
on Mar 17, 2010
(permalink)
Hello,
The MouseDown and MouseMove events will not fire when RadGridView is in edit mode - this is by design.
When RadGridView is in edit mode, the editor will have the focus and it will process all mouse and keyboard events.
In case you see a different behavior, please open a support ticket and send us your application, so that we can research the issue in detail.
Greetings,
Jack
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.
Reply
Mario
Posted
on Nov 8, 2010
(permalink)
When I try to compile I get this error:
error CS1061: 'Telerik.WinControls.UI.GridViewDataRowInfo' does not contain a definition for 'VisualElement' and no extension method 'VisualElement' accepting a first argument of type 'Telerik.WinControls.UI.GridViewDataRowInfo' could be found (are you missing a using directive or an assembly reference?)
Reply
Posted
on Nov 9, 2010
(permalink)
Hello Mario,
Sorry, the new virtualization engine is not using VisualElements anymore, this is one of the many changes introduced in Q2 2010, for drag and drop between grids in unbound mode please take a look at the Demos application, you will find an example on how to do this with the new grid there.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Reply
Jack
Jack
Posted
on Nov 11, 2010
(permalink)
Hi Mario,
You can find more information on why we removed
CellElement and
VisualElement properties in this
blog article. We will be glad to assist you in case you have any other issues when updating to the latest release.
All the best,
Jack
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
Reply
Mario
Posted
on Nov 11, 2010
(permalink)
Thanks, I will take a look at the new drag'n'drop demo.
Reply