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

8 posts, 0 answers
  1. Pradnya
    Pradnya avatar
    31 posts
    Member since:
    Aug 2011

    Posted 09 Apr 2012 Link to this post

    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-

     

  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 09 Apr 2012 Link to this post

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

  3. Pradnya
    Pradnya avatar
    31 posts
    Member since:
    Aug 2011

    Posted 09 Apr 2012 Link to this post

    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-
  4. Pradnya
    Pradnya avatar
    31 posts
    Member since:
    Aug 2011

    Posted 09 Apr 2012 Link to this post

    I mean I want to update specific column and Specefic row value not a column header value.
  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 09 Apr 2012 Link to this post

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

  6. Pradnya
    Pradnya avatar
    31 posts
    Member since:
    Aug 2011

    Posted 09 Apr 2012 Link to this post

    Where I can set RadDragAndDropManager.AllowDrop to true on the Cells in xaml or in code behind

    Thanks-
  7. Pradnya
    Pradnya avatar
    31 posts
    Member since:
    Aug 2011

    Posted 09 Apr 2012 Link to this post

    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.

  8. Nick
    Admin
    Nick avatar
    593 posts

    Posted 10 Apr 2012 Link to this post

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

Back to Top