TreeList - how to remove all rows

3 posts, 0 answers
  1. Dave
    Dave avatar
    10 posts
    Member since:
    Nov 2015

    Posted 07 Mar Link to this post

    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. Patrick
    Admin
    Patrick avatar
    173 posts

    Posted 07 Mar Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Dave
    Dave avatar
    10 posts
    Member since:
    Nov 2015

    Posted 07 Mar in reply to Patrick Link to this post

    Patrick,

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

    Dave

Back to Top