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

On single click of Button Expand KendoUI TreeView in Jquery - Its not repatitive question

4 Answers 248 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Kannan
Top achievements
Rank 1
Kannan asked on 22 Oct 2018, 11:49 PM

Dear All,

I am new to Kendo control, please help me with this, I already have Tree View as shown in the attachment, Now I have Expand onclick of button, I know the code to perform Expand, but it doesn't expand complete child nodes, instead it does just only 1 immediate child, if it has more child, we need to keep clicking the Expand button then it does the expand. Please help me how to achive on single click to Expand all the Parent and Child nodes.

Its not repatitive question, I have already searched here,Please help me.

This is My code:   
                  $("#expand").on("click", function(){
                    var treeview = $("#treeview").data("kendoTreeView");
                              treeview.expand(".k-item");
                    })

4 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 24 Oct 2018, 02:15 PM
Hi,

See this dojo example, which demonstrates a possible approach using the expand and dataBound event handlers of the TreeView.

Regards,
Ivan Danchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Kannan
Top achievements
Rank 1
answered on 25 Oct 2018, 02:03 PM
Hi Ivan, Thanks for your response, I need to expand all the tree, on click of button  without using recursion method and with good performance.  At present I am able to achieve Expand all on click of button using recursion , but for big hierarchy like hierarchy level 9 or 10 , its taking very long time to respond, almost 50 seconds, which is not feasible, so could you please guide me how I can do that without recursion.
0
Accepted
Ivan Danchev
Telerik team
answered on 26 Oct 2018, 10:36 AM
Hi Kannan,

The other known approach for expanding child nodes on clicking the expand arrow is to use the dataBound event handler and expand the node's children as shown below:
dataBound: function(e) {
  $(".k-i-expand").click(function() {
    var childNodes = $(this).parents("li").find(".k-item");
    $("#treeview").data("kendoTreeView").expand(childNodes);
  });
}

For this approach to work all nodes must be loaded initially, which means loadOnDemand should be set to false. Thus it is not recommended in case there is a lot of data loaded into the TreeView.

Regards,
Ivan Danchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Kannan
Top achievements
Rank 1
answered on 30 Oct 2018, 12:02 AM
Hi Ivan, Thanks a lot for the response.
Tags
Data Source
Asked by
Kannan
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Kannan
Top achievements
Rank 1
Share this question
or