how to now if a task has child expanded or not

Good morning,

i would like to know if there is a way to know ia a task with child is expanded or not in ganttgrid

Thank You


Best regards

Marco Del frate


3 Replies

VR Vallarasu Ravichandran Syncfusion Team October 27, 2025 01:36 PM UTC

Hi Marco Del frate,


We have reviewed your query. To receive notifications when expanding or collapsing items in the GanttGrid, you can use the NodeExpanded and NodeCollapsed events. The NodeExpanded event is triggered when a task is expanded, while the NodeCollapsed event is triggered when a task is collapsed, as demonstrated in the following code snippet.

 

XAML:

<syncfusion:GanttControl x:Name="Gantt"
                           ItemsSource="{Binding TaskCollection}"
                           Loaded="OnGanttLoaded"/>

 

C#:

       private void OnGanttLoaded(object sender, RoutedEventArgs e)
        {
this.Gantt.GanttGrid.NodeExpanded += OnGanttGridNodeExpanded;
            this.Gantt.GanttGrid.NodeCollapsed += OnGanttGridNodeCollapsed;
        }

        private void OnGanttGridNodeCollapsed(object? sender, NodeCollapsedEventArgs e)
        {

        }

        private void OnGanttGridNodeExpanded(object? sender, Syncfusion.UI.Xaml.TreeGrid.NodeExpandedEventArgs e)
        {

        }

We hope this information helps. If you need further assistance, please don't hesitate to reach out.

 

Regards,
Vallarasu R.




MD marco del frate October 28, 2025 08:43 AM UTC

Good morning and thank You for YOur answer.

This could be an option but i would like to know if there is a property i can check when i need it.

I don't need to know "when" it has been expanded or collapsed but just if it is expanded or not when i want to print it.

Thank You 

Best regards

Marco Del Frate



VR Vallarasu Ravichandran Syncfusion Team October 29, 2025 11:29 AM UTC

Hi marco del frate,

# Regarding Would like to know if there is a way to know ia a task with child is expanded or not in ganttgrid.

To achieve this requirement, you can utilize the IsExpanded property available in the RootNodes collection of the GanttGrid. By identifying the index of the root node, you can check or set the IsExpanded property to determine whether that specific node is currently expanded or collapsed, as demonstrated in the following code snippet.

C#:

private void OnCheckIsExpandedOrNot(object sender, RoutedEventArgs e)

{

   var isExpanded = this.GanttControlInstance.GanttGrid.View.Nodes.RootNodes[2].IsExpanded;

}

 

 

 

Please review the provided code and let us know whether this meets your requirements.

We hope this information helps. If you need further assistance, please don't hesitate to reach out.

Regards,

Vallarasu R.



Loader.
Up arrow icon