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

Drag and Drop functionality with RadGridView and Re-ordering Grid Row

7 Answers 132 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pradnya
Top achievements
Rank 1
Pradnya asked on 09 Apr 2012, 10:58 AM

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

Sort by
0
Nick
Telerik team
answered on 09 Apr 2012, 12:43 PM
Hello Pradnya,

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 >>

0
Pradnya
Top achievements
Rank 1
answered on 09 Apr 2012, 02:42 PM
Thank you for your reply,

if I make ExecutionMode = DragExecutionMode.Disabled then how can I register AddDragQueryHandler, AddDropQueryHandler.

Can you please provide some sample for above scenario.

Thanks-
0
Pradnya
Top achievements
Rank 1
answered on 09 Apr 2012, 03:08 PM
I mean I want to update specific column and Specefic row value not a column header value.
0
Nick
Telerik team
answered on 09 Apr 2012, 03:21 PM
Hi Pradnya,

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! 

Greetings,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Pradnya
Top achievements
Rank 1
answered on 09 Apr 2012, 04:03 PM
Where I can set RadDragAndDropManager.AllowDrop to true on the Cells in xaml or in code behind

Thanks-
0
Pradnya
Top achievements
Rank 1
answered on 09 Apr 2012, 04:40 PM
I tried using following way

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.

0
Nick
Telerik team
answered on 10 Apr 2012, 08:50 AM
Hello Pradnya,

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 >>

Tags
GridView
Asked by
Pradnya
Top achievements
Rank 1
Answers by
Nick
Telerik team
Pradnya
Top achievements
Rank 1
Share this question
or