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

[Solved] HtmlAttributes when using Model binding

2 Answers 160 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tx3
Top achievements
Rank 1
Tx3 asked on 03 May 2010, 01:58 PM

Hi,

Another question raised when I was implementing TreeView on my site. I need to set each item HtmlAttributes, but unfortunately I didn't find example how this done when using Binding. Below is a code where I have tried to set it. Normally I have done like this: .HtmlAttributes(new {style = "width:1px;"});

        mappings.For<Branch>(binding => binding                                  
                .ItemDataBound((item, branch) =>  

                {  

                    item.HtmlAttributes = ???

                    item.Selected = branch.IsSelected;  
                    item.Expanded = branch.IsExpanded;                      
                    item.Encoded = false;  
                    item.Text = branch.Name + "<span class=\"treeViewActions\">" + BranchHelper.GetActions(branch) + "</span>";  
                })  
                .Children(branch => branch.Versions));  
        mappings.For<Leaf>(binding => binding  
                .ItemDataBound((item, version) =>  
                {                      
                    item.Selected = version.IsSelected;  
                    item.Encoded = false;  
                    item.Text = version.Name + "<span style=\"position: absolute; right: 65%;\">" + version.StatusText + "</span><span class=\"treeViewActions\"\">" + ItemHelper.GetVersionActions(version) + "</span>";  
                })); 

Thanks,

-Tatu

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 03 May 2010, 02:02 PM
Hello Tx3,

item.HtmlAttributes is a dictionary:

item.HtmlAttributes["class"] = "myClass";


Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Tx3
Top achievements
Rank 1
answered on 04 May 2010, 06:33 AM
Thanks! That was exactly what I wanted
Tags
TreeView
Asked by
Tx3
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Tx3
Top achievements
Rank 1
Share this question
or