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

formating json to populate a treeview

2 Answers 420 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 24 Aug 2016, 08:53 AM

Hi I have an ajax call which returns a json string which consists of -

"{"d":[{"path":"/","e_type":"d ","text":"/"},

{"path":"//SQL","e_type":"d ","text":"//SQL"},

{"path":"//SQL/SourceClips","e_type":"d ","text":"//SQL/SourceClips"},

{"path":"//SQL/SourceClips/kjpDNxHD145_MC403.mov","e_type":"f ","text":"//SQL/SourceClips/kjpDNxHD145_MC403.mov"}]}"

 

I am trying to format this so there are 3 folders and one file inside the 3rd folder in the tree view. I want to use a loop so i can reuse this for any data I return.

Currently that is fine as far as printing each item on separate lines but i am trying to nest the last item into the third item.

 

Any help would be very appreciated.

     

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 26 Aug 2016, 07:25 AM
Hello,

Assuming that the files should be nested in the directory with the longest matching path, you can use approach similar to the one demonstrated in this example to create the data.

Regards,
Daniel
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Paul
Top achievements
Rank 1
answered on 26 Aug 2016, 08:45 AM
THis is perfect thank you.
Tags
TreeView
Asked by
Paul
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Paul
Top achievements
Rank 1
Share this question
or