GanttView collapse groups on load

Posted by: jay on 24 January 2019, 3:42 am EST

    • Post Options:
    • Link

    Posted 24 January 2019, 3:42 am EST - Updated 4 October 2022, 1:38 am EST

    I’m looking to open a chart that has all groups collapsed when open. I haven’t been able to find a option under properties for this. I’ve also tried to do this in code, but haven’t found a way to get this working. See picture which shows how I would like it to open.

  • Posted 25 January 2019, 1:34 am EST

    Hi Jay,

    You can use this method to collapse all the groups:

    private void CollapseGroupTasks()
    {
        var flex = c1GanttView1.Controls[2] as C1.Win.C1FlexGrid.C1FlexGrid;
    
        for (int row = 0; row < flex.Rows.Count; ++row)
        {
            var dataSource = flex.Rows[row].DataSource;
            if (dataSource != null && 
                    dataSource.GetType().FullName.Equals("C1.Win.C1GanttView.GroupTask"))
            {
                    var task = dataSource as C1.Win.C1GanttView.BaseTask;
                    task.IsCollapsed = true;
            }
        }
    }
    

    You can also refer to the attached sample for the same.

    Regards,

    Jitender

    CollapseGroupTasks.zip

  • Posted 25 January 2019, 4:56 am EST

    Didn’t quite work in VB.net after conversion but with minor changes I was able to get it to work. Definitely pointed me in the right direction. I didn’t think about modifying it that way before. Thanks so much for your help.

Need extra support?

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

Learn More

Forum Channels