Expanding / Collapse ChildGridViewTemplate without Activating Double-Click Action

8 posts, 0 answers
  1. Tom Chien
    Tom Chien avatar
    125 posts
    Member since:
    Jun 2009

    Posted 02 Dec 2009 Link to this post

    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.


  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 03 Dec 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Tom Chien
    Tom Chien avatar
    125 posts
    Member since:
    Jun 2009

    Posted 03 Dec 2009 Link to this post

    Thanks, that fixed it, partially.  It works for the MasterGridViewTemplate, but not for ChildGridViewTemplates, apparently because GetCellElement is returning Nothing in those cases.


  5. Svett
    Admin
    Svett avatar
    728 posts

    Posted 04 Dec 2009 Link to this post

    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.
  6. Tom Chien
    Tom Chien avatar
    125 posts
    Member since:
    Jun 2009

    Posted 04 Dec 2009 Link to this post

    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.

  7. Svett
    Admin
    Svett avatar
    728 posts

    Posted 08 Dec 2009 Link to this post

    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.
  8. Tom Chien
    Tom Chien avatar
    125 posts
    Member since:
    Jun 2009

    Posted 09 Dec 2009 Link to this post

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

  9. Svett
    Admin
    Svett avatar
    728 posts

    Posted 10 Dec 2009 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready