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

"MouseDown / Expand-Collapse" Issue

9 Answers 131 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 27 Nov 2014, 10:49 AM
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

9 Answers, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 1
answered on 27 Nov 2014, 03:56 PM
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.
0
Eric
Top achievements
Rank 1
answered on 27 Nov 2014, 04:06 PM
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.
0
Eric
Top achievements
Rank 1
answered on 27 Nov 2014, 04:20 PM
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?
0
Ali
Top achievements
Rank 1
answered on 01 Dec 2014, 08:11 AM
Any idea?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Dec 2014, 08:29 AM
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.

 
0
Ali
Top achievements
Rank 1
answered on 03 Dec 2014, 06:31 AM
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
0
Stuart
Top achievements
Rank 1
answered on 05 Dec 2014, 04:30 PM
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.
0
Ivan Petrov
Telerik team
answered on 05 Dec 2014, 04:54 PM
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.

 
0
Ali
Top achievements
Rank 1
answered on 06 Dec 2014, 07:36 AM
Hi Ivan
Thanks for the answer.

It's working now.

Kind Regards
Ali
Tags
GridView
Asked by
Ali
Top achievements
Rank 1
Answers by
Eric
Top achievements
Rank 1
Ali
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Stuart
Top achievements
Rank 1
Ivan Petrov
Telerik team
Share this question
or