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

Images using Razor

1 Answer 16 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 03 Sep 2015, 05:25 PM

Hi,

just started using TreeView...

 

I have a Treeview that calls a controller to load some JSON data - format of the JSON data is under my control, so changeable. 

 

[{"Id":3,"Name":"Business Components","UrlImage":"B_Capability.png","HasChildren":0},{"Id":4,"Name":"Business Processes","UrlImage":"B_Process.png","HasChildren":0},{"Id":17,"Name":"Goals and Objectives","UrlImage":"B_Goal.png","HasChildren":0},{"Id":12,"Name":"Org Units","UrlImage":"B_OrgUnit.png","HasChildren":0},{"Id":2,"Name":"Associates","UrlImage":"B_Associate.png","HasChildren":0},{"Id":11,"Name":"Locations","UrlImage":"B_Location.png","HasChildren":0},{"Id":5,"Name":"Business Rules","UrlImage":"B_Rule.png","HasChildren":0},{"Id":15,"Name":"Programs","UrlImage":"B_Programme.png","HasChildren":0},{"Id":16,"Name":"Projects","UrlImage":"B_Project.png","HasChildren":0}]

In the dataset I return an image which I would like to display in the tree. All the examples I can find just load data from some datasource in javascript, but I cannot find anything that does this dynamically. 

 

What do I have to add to this code to make this work?

             @(Html.Kendo().TreeView()
                .Name("treeview4")
                .DataTextField("Name")
                .DataSource(dataSource => dataSource
                    .Read(read => read.Action("DomainObjects", "Tree", new { name = "id", id = 4 })))

Thanks for the help in advance.

 

Matt

 

1 Answer, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 04 Sep 2015, 12:44 PM

Figured it out:

 

                .DataImageUrlField("UrlImage")

Matt​

Tags
TreeView
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Share this question
or