Hierarchical Grid Property and Child Row Collapsing

7 posts, 0 answers
  1. Gary
    Gary avatar
    23 posts
    Member since:
    Jul 2016

    Posted 02 Feb 2018 Link to this post

    I have my gridview working with data tables for the data sources for both the master template and the child template.  Can you tell me how to do two things?

    1.  I would like to set the width for that column that expands and collapses the child rows.  (It has that [+] and [-] symbol in it.)

    2. Is there a way to collapse the child rows for a parent row when I click to expand a different parent row?

     

    Thank you,

    Gary

  2. Gary
    Gary avatar
    23 posts
    Member since:
    Jul 2016

    Posted 02 Feb 2018 Link to this post

    I found a previous post regarding collapsing other rows and implemented this version of that:

    private void gvPickLocations_ChildViewExpanding(object sender, ChildViewExpandingEventArgs e)
     {
         GridViewTemplate template = e.ParentRow.ViewTemplate;
         foreach (GridViewRowInfo row in template.Rows)
         {
             if (row != e.ParentRow)
             {
                 row.IsExpanded = false;
             }
     
         }

     

     

  3. Gary
    Gary avatar
    23 posts
    Member since:
    Jul 2016

    Posted 02 Feb 2018 Link to this post

    Can I also hide that [+] icon when the parent row has no child rows?

    In my application, this gridview is essentially read only.  Nothing is being added, edited, or deleted.

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3089 posts

    Posted 05 Feb 2018 Link to this post

    Hello, Gary,

    Thank you for writing.  

    Indeed, setting the row's IsExpanded property allows you managing whether a row is expanded or not. 

    I would recommend you to have a look at the following help article demonstrating how to hide the expander icons for parent rows that don't have any children: https://docs.telerik.com/devtools/winforms/gridview/cells/formating-examples/child-tabs

    As to the width of the expander column, you can set the RadGridView.TableElement.GroupIndent property to the desired width.

    I hope this information helps. Should you have further questions I would be glad to help. 
     
     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Gary
    Gary avatar
    23 posts
    Member since:
    Jul 2016

    Posted 05 Feb 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Dess,
    Thank you.  I'm working through the solution for the expander icons for the parent rows.  My grid has one child template.  I ran into two issues with the cell formatting method:

    1.In this part of the code

    else if (cell != null)
        {
            GridViewHierarchyRowInfo hierarchyRow = (GridViewHierarchyRowInfo)((GridViewDetailsRowInfo)cell.RowInfo).Owner;
            for (int i = 0; i < cell.PageViewElement.Items.Count; i++)
            {

    I get an error because cell.PageViewElement is null (sometimes).  So I added a test: else if (cell != null && cell.PageViewElement != null) to get around that.

     

    2. When the grid is first displayed, none of the parent rows have the expander element visible.  I have to click on the cell for each row and the expander element will become visible if that row has child rows.

     

    I'm working though it but if you have additional information I would like to know about that.

     

    Thank you,

    Gary

     

     

  6. Gary
    Gary avatar
    23 posts
    Member since:
    Jul 2016

    Posted 05 Feb 2018 in reply to Gary Link to this post

    I found a pattern that happens consistently concerning the expander images that are not visible when the grid is rendered.

    The last parent row that should display the image doesn't.  Parent rows above that row do display the image.  If, after the form displays the gridview, I immediately execute the code to load the gridview's datasources again, all rows that should display the expander image do.

  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3089 posts

    Posted 06 Feb 2018 Link to this post

    Hello, Gary,  

    Thank you for writing back. 

    In case your hierarchical grid has only one child template, you don't have a tabbed view when expanding a parent row. That is why you obtain the exception. However, in this case you don't need to hide the child tabs because you are actually not expected to see them. I referred a wrong article in my previous post. Please excuse me for the misunderstanding. You just need to hide the expander sign "+" when no child rows are available. The following KB article demonstrates a sample code snippet how to achieve it: https://www.telerik.com/support/kb/winforms/gridview/details/hide-expand-collapse-image-in-hierarchical-radgridview

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top