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

TreeList - how to remove all rows

2 Answers 538 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 07 Mar 2016, 06:44 PM

Hello,

I have a TreeList which I display rows of data and child data.  I want to click a button and fire off a javascript call to completely clear the TreeList.  I have tried various things and have googled this issue but have not found a solution.  I'm surprised there is not a method for this, something like:

var treelist = $("#myTreeList").data("kendoTreeList");

treeList.Data.ClearAll(). 

Is there such a function/method?

I have the buttonClick event no problem but just need the code for deleting all the rows. Can you tell me how to do this please?

Thank you very much...

Dave

 

2 Answers, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 07 Mar 2016, 09:01 PM
Hello Dave,

Please take a look at this Telerik Dojo which shows how to clear a datasource, which in turn clears all rows.  

The method I used was .setDataSource, and I set data to an empty array:
//Clear DataSource
$("#btnClear").click(function() {
var treelist = $("#treelist").data("kendoTreeList");

//empty datasource
var emptyDataSource = new kendo.data.DataSource({
  data: []
});

//setting the datasource of the treelist
treelist.setDataSource(emptyDataSource); 
});
 
Hopefully, this helps.

Regards,
Patrick
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Dave
Top achievements
Rank 1
answered on 08 Mar 2016, 12:10 AM

Patrick,

Thanks very much for the quick reply.  That worked.  Thanks for the code snippet!

Dave

Tags
TreeList
Asked by
Dave
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Dave
Top achievements
Rank 1
Share this question
or