Collapse/Expand All Groups in C1GridView

Posted by: sapientcoder on 10 September 2017, 11:42 am EST

  • Posted 10 September 2017, 11:42 am EST

    I'm working with a client who would like a "collapse/expand all" capability added for the groups in a C1GridView. I looked over the documentation for C1GridView (and the client-side Wijgrid control that it uses) but didn't see an obvious way to programmatically collapse/expand a group.

    Can anyone point me in the right direction or provide some sample code?

    Thanks!
  • Replied 10 September 2017, 11:42 am EST

    To expand/collapse all groups at once, you'll have to set the OutlineMode property accordingly. I've implemented this at button clicks as below:

    protected void Button1_Click(object sender, EventArgs e)

    {

    C1BoundField col = (C1BoundField)C1GridView1.Columns[4];



    if (col.GroupInfo.OutlineMode == OutlineMode.StartCollapsed || col.GroupInfo.OutlineMode == OutlineMode.None)

    {

    col.GroupInfo.OutlineMode = OutlineMode.StartExpanded;

    }



    C1GridView1.DataSource = GetDataSet();

    C1GridView1.DataBind();

    }



    protected void Button2_Click(object sender, EventArgs e)

    {



    C1BoundField col = (C1BoundField)C1GridView1.Columns[4];



    if (col.GroupInfo.OutlineMode == OutlineMode.StartExpanded || col.GroupInfo.OutlineMode == OutlineMode.None)

    {

    col.GroupInfo.OutlineMode = OutlineMode.StartCollapsed;

    }



    C1GridView1.DataSource = GetDataSet();

    C1GridView1.DataBind();

    }

    '4' is the index of that column on which the GroupInfo property is applied.

    Have a look at the attached sample for the complete implementation.

    Regards
    2011/12/C1GridViewWijmo_ExpandCollapseGroups.zip
  • Replied 10 September 2017, 11:42 am EST

    AbdiasM -- Thanks for the sample code. Can the same be done client-side (using JavaScript)? I was trying to avoid doing postbacks, if possible. I was hoping that maybe the Wijgrid control (client-side JS control for the grid) exposed a function through its API to expand/collapse its groups.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels