We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Childnodes are not filled in Level 4

Hi Syncfusion team,

I have a STTreeView to map a complex production parts list and I expand the current node and its parents manually. It's made recursive in code but if the current node is in level 4 or lower the ChildNodes collection is not filled anymore. My binded ChildProperty "Substueckliste" is filled and it's shown in the treeview but the ChildNodes are not. 
Can you look over it? I've attached screenshots and the code snippets are below:


Codebehind, function to expand the current node:

    private void treeView_Loaded(object sender, Syncfusion.XForms.TreeView.TreeViewLoadedEventArgs e)
        {
            if (treeView.Nodes != null)
            {
                GetCurrentNode(treeView.Nodes);
            }
        }

        private void GetCurrentNode(TreeViewNodeCollection nodeCollection)
        {
            foreach (var node in nodeCollection)
            {
                var content = (StueckListeItem)node.Content;
                var childnodes = node.ChildNodes;
                if ((childnodes != null && childnodes.Count() > 0) || content.SubStueckliste != null && content.SubStueckliste.Count() > 0)
                {
                    GetCurrentNode(childnodes);
                }

                if (content.StuecklisteProperties.Gefertigt > 0 && content.StuecklisteProperties.Menge > 0 && content.StuecklisteProperties.Gefertigt >= content.StuecklisteProperties.Menge)
                {
                    content.IstErledigt = true;
                    node.IsChecked = true;
                }

                if (content.StuecklisteProperties.BelId == viewModel.BelId)
                {               
                    node.IsExpanded = true;
                    expandParentRecursive(node);
                }
            }
        }
        private void expandParentRecursive(TreeViewNode node)
        {
            if (node != null && node.ParentNode != null)
            {
                node.ParentNode.IsExpanded = true;
                this.expandParentRecursive(node.ParentNode);
            }
        }


XAML:
 <StackLayout VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand">
            <syncfusion:SfTreeView x:Name="treeView"
                                    ItemHeight="40"
                                    Indentation="30"
                                    ExpanderWidth="20"
                                    Loaded="treeView_Loaded"
                                    ChildPropertyName="SubStueckliste"
                                    ItemsSource="{Binding StuecklisteList}"  
                                    AutoExpandMode="RootNodesExpanded">
                <syncfusion:SfTreeView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.View>
                                <Grid RowSpacing="0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="40" />
                                        <ColumnDefinition Width="40" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid Grid.Column="0" Padding="5">
                                        <Image Source="{Binding RessourceImg}" VerticalOptions="Center" HorizontalOptions="Center" HeightRequest="35" WidthRequest="35"/>
                                    </Grid>
                                    <Grid Grid.Column="1" Padding="5">
                                        <Label Text="&#xf00c;" IsVisible="{Binding IstErledigt}" TextColor="#F1700A" FontFamily="fa-solid-900.ttf#Font Awesome 5 Pro Solid" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" FontSize="24"/>
                                    </Grid>
                                    <Grid Grid.Column="2" RowSpacing="1" Padding="-5" >
                                        <Label Text="{Binding Beschreibung}" FontAttributes="{Binding FontAttribute}" FontSize="18"/>
                                    </Grid>
                                </Grid>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </syncfusion:SfTreeView.ItemTemplate>
            </syncfusion:SfTreeView>
        </StackLayout>


Thanks in advance :)

Maria

Attachment: Screenshots_TreeviewChildnodes_861fe0.zip

3 Replies

SS SaiGanesh Sakthivel Syncfusion Team March 30, 2020 12:51 PM UTC

Hi Maria, 
 
Thank you for the contacting syncfusion support. 
 
We have checked the reported issue “Childnodes are not filled in Level 4” from our end. We regret to inform that the issue is not replicated from our side. We have attached the test sample and image in the following link. 
 
 
 
let us know it you still facing the same issue. If not, could you please share the following details which would be helpful for us to check on it and provide you the solution at the earliest.  
 
·       Modify our sample / Share layouts used in Xaml page 
·       Synfusion and Xamarin Forms updated version 
 
Regards, 
SaiGanesh Sakthivel


AN Andy April 1, 2020 06:57 AM UTC

Hi, 

thanks for your quick answer!

The issure occures if you set  AutoExpandMode="RootNodesExpanded" as in my example. If it is AllNodesExpanded the items are filled.
Picture is attached.

Regards, 
Maria

Attachment: RootNodesExpanded_ChildnodesEmpty_6e674e05.zip


SS SaiGanesh Sakthivel Syncfusion Team April 2, 2020 03:01 PM UTC

Hi Maria, 
 
Thank you for the update. 
 
We have checked the reported query “Childnodes are not filled in Level 4” from our end. We would like to inform that you can achieved your requirement by setting NodePopulationNode into “Instant” to populates all the child nodes when the SfTreeView control is initially loaded. Please refer the following code snippet. 
 
Code Snippet 
<syncfusion:SfTreeView x:Name="treeView" 
                            ItemHeight="40" 
                            Indentation="30" 
                            ExpanderWidth="20" 
                            Loaded="treeView_Loaded" 
                            ChildPropertyName="SubFiles" 
                            ItemsSource="{Binding ImageNodeInfo}"   
                            AutoExpandMode="RootNodesExpanded" NodePopulationMode="Instant"> 
 
We have attached the sample for your reference in the following link. 
 
 
Please refer the following UG link for your reference. 
 
 
Please let us know if the solution helps. 
 
Regards, 
SaiGanesh Sakthivel 


Loader.
Up arrow icon