This is a migrated thread and some comments may be shown as answers.
Duplicated tree using Content
2 Answers 33 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jero
Top achievements
Rank 1
Jero asked on 14 May 2012, 01:52 PM
Hi, I try to set my own content for a tree view using .Content and a partial view, but when it loads the tree is appears duplicated, first appear the tree with my template, and under that a treeview empty, any ideas?

View:

@model IEnumerable<ImportOrder>
 
 @( Html.Telerik().TreeView()
    .Name("TreeView")
    .DragAndDrop(true)
    .ClientEvents(events => events
        .OnNodeDragging("onNodeDragging")
    )         
    .BindTo(Model, mappings => {
        mappings.For<ImportOrder>(binding => binding
            .ItemDataBound((item, ImportOrder) =>
            {
                item.Content = () => { Html.RenderPartial("ItemOrderNode", ImportOrder); };               
            }));                   
    })          
 )


Partial view:

@model ImportOrder
 
Template node test...


2 Answers, 1 is accepted

Sort by
0
Accepted
Pechka
Top achievements
Rank 1
answered on 15 May 2012, 07:56 AM
Hi

Instead of using @(Html.blabla) try to use @{Html.blabla.Render();}
0
Jero
Top achievements
Rank 1
answered on 15 May 2012, 08:53 AM
Thanks for response!

it works, now the tree view is not duplicated. although I really don't understand what is the difference about using @{}.Render instead @(), I have started with MVC just a couple of days ago.

One more question I have is why now my template is rendered nested, I mean, each node appears like an arrow icon with no text, when I click on it the node is expanded and then my template appears. What I really want is to render my template in a plain way, without nesting. Maybe I am wrong but I think what I really need is set a parent node with a text, and the create all my nodes as content, but don't know how to do that.

This is what is rendered inside each <li> element:
<div class="t-mid">
    <span class="t-icon t-minus"></span>
      <
a class="t-link t-in" href="#TreeView-2"></a>
</div>
 
<div class="t-content" id="TreeView-2" style="">
      <!-- This is my template content: -->
    <input checked="checked" id="myCheckBox" name="myCheckBox" type="checkbox"
value="true">
    <input name="myCheckBox" type="hidden" value="false">
    Hello, this is a test.
</div>
Tags
TreeView
Asked by
Jero
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Jero
Top achievements
Rank 1
Share this question
or