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

[Solved] How to embed a Telerik Treeview into a PanelBar

5 Answers 35 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dominique
Top achievements
Rank 1
Dominique asked on 08 Nov 2011, 05:10 PM
Hi all,
  What is the correct way to embed a Telerik TreeView as one of the PanelBar items?
There may also be other items in that section where the Treeview exists.
I searched on the internet but could not find an example of how to do this.

Thanks,


D.

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 09 Nov 2011, 04:10 PM
Hello Dominique,

 You can do this by defining the item content. You can see this approach in action in this demo.


All the best,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Dominique
Top achievements
Rank 1
answered on 09 Nov 2011, 07:39 PM
HI Georgi,
  Thanks for taking the time to reply to my query...

I did try...
.Content(@<text>
                     Html.Telerik().TreeView()
                         .Name("TreeView")
                         .Items(item =>
                         {
                             item.Add()
                                 .Text("Mail")
                                 .ImageUrl("~/Content/images/icon_servicemaster.png")
                                 .ImageHtmlAttributes(new { alt = "Mail Icon" });
                         })
                        </text>
                    );
and

.Content(() =>
                   {
                       Html.Telerik().TreeView()
                         .Name("TreeView")
                         .Items(item =>
                         {
                             item.Add()
                                 .Text("Mail")
                                 .ImageUrl("~/Content/images/icon_servicemaster.png")
                                 .ImageHtmlAttributes(new { alt = "Mail Icon" });
                         });                        
                   });

But both of these gave undesirable results. The second gave very unpredictable results.

Also the demos only show really simple scenarios like adding straight HTML tags, and not how to emed controls within controls.
0
Dominique
Top achievements
Rank 1
answered on 09 Nov 2011, 08:02 PM
HI Georgi,
  I've found the error of my ways. I was using @( instead of @{ and that caused loads of issues. can the compiler warn about that sort of thing?

Thanks,


D.
0
Shanmuga
Top achievements
Rank 1
answered on 20 Nov 2011, 10:13 AM
I have lot of rendering issues having treeview within panel bar. I am using razer view.
I have the following code to render Panel Bar:

<div id="div1" class="class1">
                    @{ Html.Telerik().PanelBar()
                           .Name("panel1")
                           .HtmlAttributes(new { style = "width: 350px; float: left; margin-bottom: 30px;" })
                           .Items(parent =>
                           {
                               foreach (var item in Model)
                               {
                                   parent.Add()
                                   .Text(item.Title)
                                   .LoadContentFrom(Url.Action("ActionName/",sControllerName));
                               }
                           })
                           .Render();
                    }
                  </div>

I have the following as treeview:
@(Html.Telerik().TreeView()
    .ExpandAll(true)
    .Name("TreeView")
    .BindTo(Model.LoadTree, mappings =>
    {
        mappings.For<Model>(binding => binding
            .ItemDataBound((item, treenode) =>
            {
                      item.Text = treenode.Name
 
                item.Value = treenode.Id.ToString();
                if (treenode.Child.Count == 0)
                {
                    item.HtmlAttributes.Add("class", "childwithclass");
                }
                else
                {
                    item.HtmlAttributes.Add("class", "childwithoutclass");
                }
            })
            .Children(treenode => treenode.Child.OrderBy(x => x.DisplayOrder)));
    })
)

It works, but the display and rendering is all over. I tried to read various posts regarding style positioning. But nothing seems to work for me or I am not very clear about where to apply that style. Can some one put me in the right direction please.

0
Dimo
Telerik team
answered on 21 Nov 2011, 02:07 PM
Hello Shanmuga,

Your code snippets work correctly on my side. There may be some additional CSS styles on the page that cause the problem. Please use Firebug to check this out. In case you need further assistance, please provide a runnable demo.

All the best,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
PanelBar
Asked by
Dominique
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Dominique
Top achievements
Rank 1
Shanmuga
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or