This example shows how to bind Telerik TreeView for ASP.NET MVC to a JSON object.

The required steps are:

  1. Attach an event handler to the OnDataBinding client-side event:
    <%= Html.Telerik().TreeView()
            .Name("TreeView")
            .ClientEvents(events => events
                .OnDataBinding("onDataBinding")
            )
    %>
    
  2. Add a data binding handler function that will load the required data and pass it to the treeview
    <script type="text/javascript">
        function onDataBinding(e) {
            var treeview = $('#TreeView').data('tTreeView');
    
            var jsonObject = [
                { Text: "Product 1", Expanded: true,
                    Items: [
                      { Text: "Product 4" },
                      { Text: "Product 5" },
                      { Text: "Product 6" },
                      { Text: "Other products", LoadOnDemand: true, Value: "other" }
                  ]
                },
                {  Text: "Product 2 (unavailable)", Enabled: false },
                {  Text: "Product 3" }
            ];
    
            treeview.bindTo(jsonObject);
        }
    </script>