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

Get serialized data from tree view?

5 Answers 501 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ingo
Top achievements
Rank 1
Ingo asked on 05 Mar 2012, 12:48 PM
Is it possible to get serialized data from the tree view - json array or something?

Thank you for your help
Ingo

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 06 Mar 2012, 08:13 AM
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!
0
Ingo
Top achievements
Rank 1
answered on 07 Mar 2012, 12:15 PM
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
0
Alex Gyoshev
Telerik team
answered on 07 Mar 2012, 05:22 PM
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!
0
Martin
Top achievements
Rank 1
answered on 04 May 2012, 03:09 PM
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
0
Alex Gyoshev
Telerik team
answered on 07 May 2012, 09:46 AM
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!
Tags
TreeView
Asked by
Ingo
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Ingo
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Share this question
or