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

TreeList Collapse event handler prevents node collapse

3 Answers 228 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 19 Sep 2017, 06:18 PM
Inside of the TreeList's collapse event handler I put the line e.model.loaded(false); to force the TreeList widget to reload the nodes every time it expands. It doesn't work properly though and it prevents the TreeList from collapsing the node.

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 21 Sep 2017, 08:25 AM
Hello, Matthew,

The issue occurs because the event is preventable, and the loaded method has to be called inside a setTimeout method.

Still, please have in mind that this will create a scenario where the TreeList dataSource will think that this model is not loaded and request and append it again. This will create duplicate DOM elements in the TreeList:

collapse: function(e) {
  setTimeout(function(){
    e.model.loaded(false);
  })
},

If the data has to be reloaded, please call the read method of the dataSource to reload the data:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-read

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Matthew
Top achievements
Rank 1
answered on 21 Sep 2017, 05:29 PM

Thanks! This works. But it seems to collapse all the rows when I collapse one row and call the datasource read method. Is there a way to do this that doesn't refresh the whole treelist view?

 

[quote]Stefan said:Hello, Matthew,

The issue occurs because the event is preventable, and the loaded method has to be called inside a setTimeout method.

Still, please have in mind that this will create a scenario where the TreeList dataSource will think that this model is not loaded and request and append it again. This will create duplicate DOM elements in the TreeList:

collapse: function(e) {
  setTimeout(function(){
    e.model.loaded(false);
  })
},

If the data has to be reloaded, please call the read method of the dataSource to reload the data:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-read

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
[/quote]
0
Stefan
Telerik team
answered on 22 Sep 2017, 08:58 AM
Hello, Matthew,

As the issue seems to be on our end based on the documentation. We will check if the scenario is no longer supported or this is an issue with the current version of the control.

As the same topic is in another forum post, I will add the answer there to avoid duplicates:

http://www.telerik.com/forums/treelist-reload-node-on-expand

Thank you in advance for the patience.

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