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

How 2 set auto Expand use TagHelper

1 Answer 110 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Iron
Vincent asked on 10 Jun 2018, 05:51 AM

I have a treeview as follow,how to set expand?

<kendo-treeview name="TvTeam"
                    style="height:calc(100vh - 95px);width:100%;border-width:thin;border-color:gainsboro"
                    datatextfield="Name" on-change="TvTeamChange" >
        <hierarchical-datasource>           
                <transport>                   
                    <read url="@Url.Content(MainPath+"?handler=LoadTree")" />
                </transport>
                <schema type="json">
                   
                    <hierarchical-model id="Id" children="Child">
                       
                    </hierarchical-model>
                </schema>
        </hierarchical-datasource>
    </kendo-treeview>


1 Answer, 1 is accepted

Sort by
0
Joana
Telerik team
answered on 13 Jun 2018, 10:34 AM
Hi Vincent,

The dataBound event of the TreeView could be used to expand items initially. I have modified the Tag Helper TreeView demo to illustrate scenario for expanding its first item :

https://demos.telerik.com/aspnet-core/treeview/tag-helper

<kendo-treeview name="treeview2" datatextfield="FullName" on-data-bound="onDataBound">
    <hierarchical-datasource>
        <transport>
            <read url="https://demos.telerik.com/kendo-ui/service/Employees" datatype="jsonp" />
        </transport>
        <schema type="json">
            <hierarchical-model id="EmployeeId" has-children="HasEmployees">
            </hierarchical-model>
        </schema>
    </hierarchical-datasource>
</kendo-treeview>
 
<script>
    function onDataBound(e) {
        if (!e.node) {
            e.sender.expand(".k-first");
        }
    }
</script>

You could find all methods and configuration settings in the following API documentation:

https://docs.telerik.com/kendo-ui/api/javascript/ui/treeview#methods

Let me know if you have further questions.

Regards,
Joana
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
TreeView
Asked by
Vincent
Top achievements
Rank 1
Iron
Answers by
Joana
Telerik team
Share this question
or