SpriteCssClass from controller

4 posts, 0 answers
  1. Mark
    Mark avatar
    10 posts
    Member since:
    Mar 2014

    Posted 06 May 2014 Link to this post

    My data is currently being bound using the TreeViewItemModel, is there any way to set the SpriteCssClasses for the items from the controller?
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 08 May 2014 Link to this post

    Hello Mark,

    Did you try to set the .DataSpriteCssClassField option for the TreeView to be the same as the property name that holds the css class, that you mentioned you want to return from the controller.

    e.g.

    @(Html.Kendo().TreeView()
        .Name("treeview")
        .HtmlAttributes(new {@class="demo-section" })
        .DataTextField("Name")
        .DataSpriteCssClassField("SpriteCssClasses")
        .DataSource(dataSource => dataSource      
            .Read(read => read
                .Action("Employees", "TreeView")
            )
        )
    )



    Kind Regards,
    Petur Subev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Mark
    Mark avatar
    10 posts
    Member since:
    Mar 2014

    Posted 09 May 2014 in reply to Petur Subev Link to this post

    Hi Petur

    I'm not sure I quite understand. The TreeViewItemModel does not have a SpriteCssClasses.
    The values from the controller are of the form:
    lastItem.Items.Add(new TreeViewItemModel { Id = svnUrl + aggregateSubPath, Text = subPath });
    And the html is:
    @(
    Html.Kendo()
        .TreeView()
        .Name("treeview")
        .BindTo((IEnumerable<TreeViewItemModel>)ViewBag.treeView)
        .DataSpriteCssClassField("SpriteCssClasses")
        .Checkboxes(checkboxes => checkboxes
            .Name("checkedFiles")
            .CheckChildren(true))
    )
    <style scoped>
        #treeview .k-sprite {
            background-image: url("@Url.Content("../../styles/Default/sprite.png")");       
        }
         
        .rootfolder { background-position: 0 0; }
        .folder     { background-position: 0 -16px; }
        .pdf        { background-position: 0 -32px; }
        .html       { background-position: 0 -48px; }
        .image      { background-position: 0 -64px; }
    </style>

    Thanks for your help.
    Mark
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 12 May 2014 Link to this post

    Hello Mark,

    Thank you for bringing this issue to our attention. Indeed the SpriteCssClass is missing from the TreeViewItemModel  class. We fixed this internally and it will become available within the next internal build.

    As a small sign of our gratitude I updated your telerik points.

    Regards,
    Petur Subev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready