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

SpriteCssClass from controller

3 Answers 102 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 07 May 2014, 03:54 AM
My data is currently being bound using the TreeViewItemModel, is there any way to set the SpriteCssClasses for the items from the controller?

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 08 May 2014, 04:00 PM
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.

 
0
Mark
Top achievements
Rank 1
answered on 09 May 2014, 08:29 AM
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
0
Petur Subev
Telerik team
answered on 12 May 2014, 07:50 AM
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.

 
Tags
TreeView
Asked by
Mark
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or