Hi
how to implement drag and drop functionality with RadGridView and on drop I want replace specific column value.
Please help me how can I Implement this scenario.
Note: I have implemented Re-ordering functionality with same GridView.
Thanks-
7 Answers, 1 is accepted
You can add Drop handler to the header row and use it to modify the column that you just dropped upon.
public
MainPage()
{
RadDragAndDropManager.ExecutionMode = DragExecutionMode.Disabled;
InitializeComponent();
this
.radGridView1.RowLoaded +=
new
EventHandler<RowLoadedEventArgs>(radGridView1_RowLoaded);
}
void
radGridView1_RowLoaded(
object
sender, RowLoadedEventArgs e)
{
if
(e.Row
is
GridViewHeaderRow)
{
DragDropManager.AddDropHandler(e.Row, OnColumnHeaderDrop,
true
);
}
}
private
void
OnColumnHeaderDrop(
object
sender, Telerik.Windows.DragDrop.DragEventArgs args)
{
var column = ((args.OriginalSource
as
FrameworkElement).ParentOfType<GridViewHeaderCell>()).Column;
}
Hope this helps!
Regards,
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
if I make ExecutionMode = DragExecutionMode.Disabled then how can I register AddDragQueryHandler, AddDropQueryHandler.
Can you please provide some sample for above scenario.
Thanks-
In that case you have to set RadDragAndDropManager.AllowDrop to true on the Cells on which you need to drop. that way in the DropInfo handler, the destination will be the GridViewCell instead of the GridViewRow.
Hope this helps!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks-
public TestPage(RuleAuthoringViewModel ruleViewModel)
{
RadDragAndDropManager.ExecutionMode = DragExecutionMode.Disabled;
InitializeComponent();
RadDragAndDropManager.AddDragQueryHandler(list, OnDragQuery);
RadDragAndDropManager.AddDropQueryHandler(gridview1.Columns[3], OnDropQuery);
RadDragAndDropManager.AddDragInfoHandler(list, OnDragInfo);
RadDragAndDropManager.AddDropInfoHandler(gridview1.Columns[3], OnDropInfo);
RadDragAndDropManager.SetAllowDrop(gridview1.Columns[3], true);
}
Getting following error
Object reference not set to an instance of an object.
You can subscribe to the RowLoaded event of the GridView and set it there.
void
GridView1_RowLoaded(
object
sender, RowLoadedEventArgs e)
{
if
(e.Row
is
GridViewRow)
{
foreach
(var cell
in
e.Row.Cells)
{
RadDragAndDropManager.SetAllowDrop(cell,
true
);
}
}
}
Hope this helps! All the best,
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>