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

Expanding / Collapse ChildGridViewTemplate without Activating Double-Click Action

7 Answers 201 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tom Chien
Top achievements
Rank 1
Tom Chien asked on 02 Dec 2009, 03:30 PM
I have the RadGridView.CellDoubleClick Handler implemented.  FYI, it's being used to open the Row being Double-Clicked in a separate Form for view / edit / delete, but that's besides point.  The problem is that it's being Triggered when I'm trying to expand / collapse ChildGridViewTemplate in quick succession (i.e. to quickly browse the ChildGridViewTemplate of a series of Rows).  This is happening with Mouse Double-Click Speed as fast as 8 / 10 not to mention the average 5 / 10 setting.  Is there a way I can detect in the RadGridView.CellDoubleClick Handler that the Cell being clicked on is a ChildGridViewTemplate Expander Cell (i.e. a GridGroupExpanderCellElement)?

Telerik WinForms 2009Q3 (2009.3.9.1103), VB, VS 2005 (v8.0.50727.762 SP.050727-7600), .Net 2.0 (2.0.50727), XP SP3, 3GB, 2.99GHZ, Core2Duo.


7 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 03 Dec 2009, 12:41 PM
Hi Tom Chien,

To detect the type of the cell that is already double clicked in CellDoubleClick even, you have to do the following:

private void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
{
    GridCellElement cellElement = this.radGridView1.GridElement.GetCellElement(e.Row, e.Column);
  
    if (cellElement is GridGroupExpanderCellElement)
    {
        // TO DO
    }
}

If you have further questions, do not hesitate to ask us.

Sincerely yours,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tom Chien
Top achievements
Rank 1
answered on 03 Dec 2009, 07:11 PM
Thanks, that fixed it, partially.  It works for the MasterGridViewTemplate, but not for ChildGridViewTemplates, apparently because GetCellElement is returning Nothing in those cases.


0
Svett
Telerik team
answered on 04 Dec 2009, 02:11 PM
Hi Tom Chien,

My recommendation is to re-engineer my old code:

private void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
{
    GridCellElement cellElement = GetCellElement(e.Row.VisualElement.BodyElement, e.Row, e.Column);
 
    if (cellElement is GridGroupExpanderCellElement)
    {
        // TO DO
    }
}
 
public GridRowElement GetRowElement(GridTableBodyElement bodyElement, GridViewRowInfo rowInfo)
{
    if (bodyElement != null && rowInfo != null)
    {
        foreach (GridRowElement row in bodyElement.Children)
        {
            if (row.RowInfo == rowInfo)
            {
                return row;
            }
        }
    }
 
    return null;
}
 
public GridCellElement GetCellElement(GridTableBodyElement bodyElement, GridViewRowInfo rowInfo, GridViewColumn column)
{
    if (bodyElement != null && rowInfo != null && column != null)
    {
        GridRowElement row = GetRowElement(bodyElement, rowInfo);
        if (row != null)
        {
            foreach (GridCellElement cell in row.Children)
            {
                if (cell.ColumnInfo == column)
                {
                    return cell;
                }
            }
        }
    }
 
    return null;
}

Greetings,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tom Chien
Top achievements
Rank 1
answered on 04 Dec 2009, 05:32 PM
1. Thanks, that fixed it work for ChildGridViewTemplates also.

2. So, why does "radGridView1.GridElement.GetCellElement(e.Row, e.Column)"  return Nothing when the Cell Double-Clicked is in a ChildGridViewTemplates?  Was that intentional?  If so, why?  If not, I'd like to submit this as a "bug report".

3. I'd like to submit the workaround for this whole thread as a "feature request".  Double-Clicking to open / perform some other default action on a selected item is a pretty common u.i. feature and when it's enabled, I can't imagine why anyone would want both the ChildGridViewTemplate expanded / collapsed AND the double-click action performed.  Therefore, it shouldn't require custom RadGridView Event code plus 2 extra Functions just to prevent that from happening for each RadGridView implemented.

0
Svett
Telerik team
answered on 08 Dec 2009, 09:14 AM
Hi Tom Chien,

GetCellElement method is related to each GridTableBodyElement. If the grid represents a hierarchy, it creates for the master template and for each child template GridTableBodyElement. In this regard, the method returns only the cell from the concrete view template.

Thank you for your feature request. It will be considered if other clients request it.

If you have further questions, feel free to contact us back.

Kind regards,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tom Chien
Top achievements
Rank 1
answered on 09 Dec 2009, 04:11 PM
Re. 2: O-kay.  I think I got it.  So, the answer is "yes" to "Was it intentional?".

Re. 3: Could I please get some points for this "feature request"?

0
Svett
Telerik team
answered on 10 Dec 2009, 08:41 AM
Hi Tom Chien,

Thank you for your effort and suggestions about our products. Your feature request is not something that cannot be achieved presently. It is noted and if more clients require it, it will be ready for the next version. Your Telerik points have been updated.

Greetings,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Tom Chien
Top achievements
Rank 1
Answers by
Svett
Telerik team
Tom Chien
Top achievements
Rank 1
Share this question
or