Images using Razor

2 posts, 0 answers
  1. Matt
    Matt avatar
    13 posts
    Member since:
    Jan 2011

    Posted 03 Sep 2015 Link to this post

    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

     

  2. Matt
    Matt avatar
    13 posts
    Member since:
    Jan 2011

    Posted 04 Sep 2015 in reply to Matt Link to this post

    Figured it out:

     

                    .DataImageUrlField("UrlImage")

    Matt​

  3. Kendo UI is VS 2017 Ready
Back to Top