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

[Solved] Problem with rendering of TreeView Content

2 Answers 82 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.
Srdjan
Top achievements
Rank 1
Srdjan asked on 03 Feb 2011, 03:43 PM
Hi I am using Telerik tree view with Ajax binding. I have a category tree where each category can have one or more categories and so on.

When I want to add custom html content to the tree view item, by using the Content property, expand/collapse buttons disappear. Also content I am setting is not displayed. When I look at the generated HTML, I can found that span with class 't-plus' and span with class 't-content' have style property set to 'display:none'.

Everything is working as expected when I remove following code:

item.Content = (() => {%> add template <%  });

Here is the code that I am using in my view and that is working as expected:

<%
    Html.Telerik().TreeView().Name("TreeView").ShowCheckBox(true).DragAndDrop(
        settings => settings.Enabled(true)).BindTo(
            Model.RootCategories,
            mappings =>
            {
                mappings.For<CategoryViewModel>(
                    binding => binding.ItemDataBound(
                        (item, category) =>
                        {
                            // bind initial data - can be omitted if there is none
                            item.Text = category.Title + "<span>bla</span>";
                            item.Value = category.CategoryID.ToString();
                            item.LoadOnDemand = category.HasChildren;
                            item.Encoded = false;
                            if (checkedNodes != null)
                            {
                                var checkedNode =
                                    checkedNodes.Where(
                                        e =>
                                        e.Value.Equals(category.CategoryID.ToString())).
                                        FirstOrDefault();
                                item.Checked = checkedNode != null
                                                   ? checkedNode.Checked
                                                   : false;
                            }
 
                                                       }));
                                       }).DataBinding(
                                           dataBinding => dataBinding.Ajax().Select("_AjaxLoading", "Category"))
                                          .ClientEvents(
                                   events =>
                                   events.OnNodeDrop("onNodeDrop").OnNodeDropped("onNodeDropped").OnSelect("onSelect").
                                       OnChecked("onChecked")).HtmlAttributes(new { @class = "t-group" }).Render();
%>

Could you please take a look into this problem?

2 Answers, 1 is accepted

Sort by
0
Diana
Top achievements
Rank 1
answered on 20 Jun 2011, 11:33 AM
Hi, I have the same problem (problems with rendering Content and missing plus buttons after adding Content section)- do you find some solutions or have any advice, how to solve this problem ?
0
Alex Gyoshev
Telerik team
answered on 21 Jun 2011, 07:28 AM
Hi Diana, Srdjan,

This appears to be a bug in the TreeView, which we will investigate. A workaround is to have an element around the template text, like

item.Content = (() => {%> <span>add template</span> <%  });

Greetings,
Alex Gyoshev
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
Tags
TreeView
Asked by
Srdjan
Top achievements
Rank 1
Answers by
Diana
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or