"MouseDown / Expand-Collapse" Issue

10 posts, 0 answers
  1. Ali
    Ali avatar
    4 posts
    Member since:
    Nov 2014

    Posted 27 Nov 2014 Link to this post

    Hello

    I have made a Hierarchy radGridView (radGridView with a Template set) and it worked pretty well , but after upgrading Telerik to v.2014.3.1021 , A problem appears in using "MouseDown" and "Expand/Collapse"  rows.
    I have set drag n drop commands in MouseDown event on the grid to drag a row and drop it...
    Before upgrade , It was possible "expand a row by clicking on it" and "Drag n Drop" both.
    but after upgrade , Expanding is not possible ; clicking on the rows calls MouseDown method , and will not expands the row.
    Is there a solution to solve it?
    (VS2010-Telerik 2014.3.1021)

    Kind Regards
    Ali
  2. Eric
    Eric avatar
    28 posts
    Member since:
    Nov 2007

    Posted 27 Nov 2014 in reply to Ali Link to this post

    We have recently upgraded to 2014.3.1104.40 and seen the same issue.  But not on all of our grids.  I'm not yet sure what the difference is between our grids that work and don't work.
  3. Eric
    Eric avatar
    28 posts
    Member since:
    Nov 2007

    Posted 27 Nov 2014 in reply to Eric Link to this post

    It's as if the grid just isn't redrawing.  My mouse cursor changes correctly, e.g. when I hover over the bottom line of a row, it changes to an up/down arrow.  And if I click and drag it down, the spot where the mouse cursor changes to an up/down arrow moves down too, but the appearance of the grid doesn't change at all.
  4. Eric
    Eric avatar
    28 posts
    Member since:
    Nov 2007

    Posted 27 Nov 2014 in reply to Eric Link to this post

    The issue was that we had an grid.SuspendUpdate() in our code, but no corresponding grid.ResumeUpdate().  This code hasn't change in a while, so perhaps the older version of the grid didn't care, but the new one does?
  5. Ali
    Ali avatar
    4 posts
    Member since:
    Nov 2014

    Posted 01 Dec 2014 Link to this post

    Any idea?
  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3204 posts

    Posted 02 Dec 2014 Link to this post

    Hello,

    Thank you for writing.

    The provided information is not enough for me to reproduce the issue on my end. You can find below my sample code snippet. The expand/collapse functionality works as expected.
    public Form1()
    {
        InitializeComponent();
        DataTable dt1 = new DataTable();
        DataTable dt2 = new DataTable();
        dt1.Columns.Add("Id", typeof(string));
        dt1.Columns.Add("MasterName", typeof(string));
     
        dt2.Columns.Add("Id", typeof(string));
        dt2.Columns.Add("ParentId", typeof(string));
        dt2.Columns.Add("Title", typeof(string));
     
        string masterId;
        string childId;
        for (int i = 0; i < 3; i++)
        {
            masterId = Guid.NewGuid().ToString();
            dt1.Rows.Add(masterId, "Item" + i);
            for (int j = 0; j < 3; j++)
            {
                childId = Guid.NewGuid().ToString();
                dt2.Rows.Add(childId, masterId, "Title" + j);
            }
        }
     
        this.radGridView1.MasterTemplate.DataSource = dt1;
        this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
         
        GridViewTemplate template = new GridViewTemplate();
        template.DataSource = dt2;
        template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        radGridView1.MasterTemplate.Templates.Add(template);
     
        GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
        relation.ChildTemplate = template;
        relation.RelationName = "FirtsLevel";
        relation.ParentColumnNames.Add("Id");
        relation.ChildColumnNames.Add("ParentId");
        radGridView1.Relations.Add(relation);
    }

    Feel free to modify the example on a way to replicate the described problem and get back to me with the code snippet. Additionally, you can refer to our GridView >> Rows >> Drag and Drop help article which is quite useful for achieving drag and drop functionality between rows.

    I am looking forward to your reply.

    Regards,
    Desislava
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Ali
    Ali avatar
    4 posts
    Member since:
    Nov 2014

    Posted 03 Dec 2014 Link to this post

    Hello Desislava
    Thank you for the answer.

    The problem appears when we have a MouseDown Event on the grid.
    I've added a MouseDown (Drag n Drop command) to the code you write.
    Here is the modified code:
        public Form1()
        {
            InitializeComponent();
            DataTable dt1 = new DataTable();
            DataTable dt2 = new DataTable();
            dt1.Columns.Add("Id", typeof(string));
            dt1.Columns.Add("MasterName", typeof(string));
     
            dt2.Columns.Add("Id", typeof(string));
            dt2.Columns.Add("ParentId", typeof(string));
            dt2.Columns.Add("Title", typeof(string));
     
            string masterId;
            string childId;
            for (int i = 0; i < 3; i++)
            {
                masterId = Guid.NewGuid().ToString();
                dt1.Rows.Add(masterId, "Item" + i);
                for (int j = 0; j < 3; j++)
                {
                    childId = Guid.NewGuid().ToString();
                    dt2.Rows.Add(childId, masterId, "Title" + j);
                }
            }
     
            this.radGridView1.MasterTemplate.DataSource = dt1;
            this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
     
            this.radGridView1.MouseDown += new MouseEventHandler(radGridView1_MouseDown);
     
            GridViewTemplate template = new GridViewTemplate();
            template.DataSource = dt2;
            template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            radGridView1.MasterTemplate.Templates.Add(template);
     
            GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
            relation.ChildTemplate = template;
            relation.RelationName = "FirtsLevel";
            relation.ParentColumnNames.Add("Id");
            relation.ChildColumnNames.Add("ParentId");
            radGridView1.Relations.Add(relation);
        }
     
        void radGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            this.DoDragDrop(sender, DragDropEffects.Copy);
        }
    }

    and expand/collapse is not active now...!

    Kind Regards
    Ali
  8. Stuart
    Stuart avatar
    1 posts
    Member since:
    Aug 2012

    Posted 05 Dec 2014 Link to this post

    Hi, i have a similar issue. I also have a gridview with drag and drop commands in the  mouse down event. Previously it was possible to resize the columns by dragging the separator bars on the header. Now the drag and drop still works, but it is not possible to resize the columns unless using the right-click context menu or double-clicking to do a column best-fit.
  9. Ivan Petrov
    Admin
    Ivan Petrov avatar
    705 posts

    Posted 05 Dec 2014 Link to this post

    Hi Ali,

    Thank you for the clarification.

    The difference in the behavior you are experiencing is coming from the fact that the expander in the newer version is expanded on mouse up instead of mouse down in the older version. This is the correct behavior for the expander but interferes with your drag drop implementation. I would suggest that you start a drag drop operation only of the user has clicked on a data cell and not the expander or the row header cells. Here is how to modify your mouse down event handler to achieve this:
    private void radGridView1_MouseDown(object sender, MouseEventArgs e)
    {
        RadElement element = this.radGridView1.ElementTree.GetElementAtPoint(e.Location);
     
        if (element != null && (element is GridDataCellElement || element.FindAncestor<GridDataCellElement>() != null))
        {
            this.DoDragDrop(sender, DragDropEffects.Copy);
        }
    }

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Ivan Petrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  10. Ali
    Ali avatar
    4 posts
    Member since:
    Nov 2014

    Posted 06 Dec 2014 Link to this post

    Hi Ivan
    Thanks for the answer.

    It's working now.

    Kind Regards
    Ali
Back to Top