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

TabStrips and Templates

1 Answer 94 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shane Milton
Top achievements
Rank 2
Shane Milton asked on 07 Dec 2010, 11:56 PM
I cannot for the life of me figure out how to use display/editor templates inside of tabs. How is this supposed to be done??

I have tried all of the following without success:
Most obvious option:
    <%
        Html.Telerik().TabStrip()
            .Name("PriceRequestDetailsTabs")
            .Items(parent =>
                       {
                           parent.Add()
                               .Text("Details")
                               .Selected(true)
                               .Content(() => Html.DisplayFor(m => m, "RetailPriceRequests/PriceRequestDetail"));
 
                           parent.Add()
                               .Text("Tier/Load Data")
                               .Content(() => {%>x<% });
                       })
            .ClientEvents(events => events.OnSelect("onSelect"))
            .Render();
%>

Hacky-but-should-be-functional option:
Html.Telerik().TabStrip()
    .Name("PriceRequestDetailsTabs")
    .Items(parent =>
               {
                   parent.Add()
                       .Text("Details")
                       .Selected(true)
                       .Content(() =>
                                    {
                                        %>
                                        <%= Html.DisplayFor(m => m, "RetailPriceRequests/PriceRequestDetail") %>
                                        <%
                                    });
 
                   parent.Add()
                       .Text("Tier/Load Data")
                       .Content(() => {%>x<% });
               })
    .ClientEvents(events => events.OnSelect("onSelect"))
    .Render();

Hackier-but-should-work option:
Html.Telerik().TabStrip()
    .Name("PriceRequestDetailsTabs")
    .Items(parent =>
               {
                   parent.Add()
                       .Text("Details")
                       .Selected(true)
                       .Content(() =>
                                    {
                                        %>
                                        <%
                                        Html.DisplayFor(m => m, "RetailPriceRequests/PriceRequestDetail").ToHtmlString(); %>
                                        <%
                                    });
 
                   parent.Add()
                       .Text("Tier/Load Data")
                       .Content(() => {%>x<% });
               })
    .ClientEvents(events => events.OnSelect("onSelect"))
    .Render();


The ONLY thing that I can get to work properly is RenderPartial but I want this done with the templates because this also breaks internal EditorFor() calls which practically means I cannot use templates at all since all of our partial views are used all over the place.

RenderPartial works:
    <%
        Html.Telerik().TabStrip()
            .Name("PriceRequestDetailsTabs")
            .Items(parent =>
                       {
                           parent.Add()
                               .Text("Details")
                               .Selected(true)
                               .Content(() => Html.RenderPartial("~/Views/Shared/DisplayTemplates/RetailPriceRequests/PriceRequestDetail.ascx", Model));
 
                           parent.Add()
                               .Text("Tier/Load Data")
                               .Content(() => {%>x<% });
                       })
            .ClientEvents(events => events.OnSelect("onSelect"))
            .Render();
%>

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Dec 2010, 08:40 AM
Hi Shane Milton,

 Does any of those work outside of the tabstrip? I am not sure that DisplayFor supports paths when specifying the name of the template ("RetailPriceRequests/PriceRequestDetail"). I thought that it just expect the name of the partial (without .ascx) and looks in the default locations. Of course I may be wrong. 
To answer your question this is the supported way of using DisplayFor inside a tabstrip:

tabs.Add().Text("First").Content(() =>
{
   %>
    <%= Html.DisplayFor(m => m) %>
   <%
});

This will also work:
tabs.Add().Text("First").Content(Html.DisplayFor(m => m).ToHtmlString());

I am sending a sample project as attachment which you can use for your reference.

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
Tags
TabStrip
Asked by
Shane Milton
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Share this question
or