Get serialized data from tree view?

6 posts, 0 answers
  1. Ingo
    Ingo avatar
    2 posts
    Member since:
    Feb 2012

    Posted 05 Mar 2012 Link to this post

    Is it possible to get serialized data from the tree view - json array or something?

    Thank you for your help
    Ingo
  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2527 posts

    Posted 06 Mar 2012 Link to this post

    Hello Ingo,

    If you want to access the data that has been passed when the treeview was initialized, you can use the get it from the options.dataSource field:

    var data = $("#tree").data("kendoTreeView").options.dataSource;

    All the best,
    Alex Gyoshev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Ingo
    Ingo avatar
    2 posts
    Member since:
    Feb 2012

    Posted 07 Mar 2012 Link to this post

    Hi Alex,

    thanks for your answer! I get the data if I am using this:
    $("#treeView").kendoTreeView({
            dataSource
    : [
               
    {
                    text
    : "Item 1",
                    items
    : [
                       
    { text: "Item 1.1" },
                       
    { text: "Item 1.2" }
                   
    ]
               
    },
               
    { text: "Item 2" }
           
    ]
       
    })

    But what if I am using an unordered list (<ul><li>item</li></ul>) - can i get a serialized array / json array from the dataSource?

    Thank you for your help!
    Ingo
  4. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2527 posts

    Posted 07 Mar 2012 Link to this post

    Hello Ingo,

    Right now, the initial data is not kept in a dataSource, so there is no array that you can get from the treeview fields. You can, however, iterate through all treeview nodes with jQuery and create the dataSource manually.

    All the best,
    Alex Gyoshev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Martin
    Martin avatar
    7 posts
    Member since:
    May 2012

    Posted 04 May 2012 Link to this post

    Hi guys, 

    Can anyone give a quick example on how to iterate through the treeview to get at complete liste of items either as array, JSON or ul/li?
    I need it to save the updated treestructure to a database.

    Kind regards
    Martin
  6. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2527 posts

    Posted 07 May 2012 Link to this post

    Hello Martin,

    I replied to your question in the other forum thread.

    Regards,
    Alex Gyoshev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top