This is a migrated thread and some comments may be shown as answers.

Always show collapse icon after clicked on expand

1 Answer 161 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Harpreet
Top achievements
Rank 1
Veteran
Harpreet asked on 09 Jul 2020, 12:20 PM

Hi All,

 

I have a requirement to show collapse icon (after clicking the expand icon) whether it has a child nodes or not.

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 13 Jul 2020, 07:59 AM

Hi Harpreet,

A possible approach to achieve the desired result is to use a template as demonstrated in the TreeView Templates Demo.

This way, if an item does not have child nodes you can show the collapse Icon:

@(Html.Kendo().TreeView()
        .Name("treeview")
        .TemplateId("treeview-template")  
     ...
    )

 

<script id="treeview-template" type="text/kendo-ui-template">
        # if (!item.items) { #
          <span class="k-icon k-i-collapse"></span>
        # } #
        #: item.text #
</script>

For items that have child nodes, the default behavior of the widget will be used and an expand icon will be rendered. Let me know if this suggestion works for you.

Regards,
Aleksandar
Progress Telerik

Tags
TreeView
Asked by
Harpreet
Top achievements
Rank 1
Veteran
Answers by
Aleksandar
Telerik team
Share this question
or