Telerik MVC 网格条件详细视图?

发布于 2024-12-13 05:18:23 字数 1268 浏览 4 评论 0原文

我正在使用 Telerik 网格。

我遇到一种情况,我必须根据条件填充详细视图。谁能给我一个想法,我该如何切换?

这是我的详细视图代码,

 .DetailView(details => details.ClientTemplate(
            Html.Telerik().TabStrip()
                .Name("TabStrip_<#= PID #>")
                .SelectedIndex(0)
                .Items(items =>
                {
                items.Add().Text("Details").LoadContentFrom("PDetails", "Med", new { id = "<#= PID #>" });
               })
                .ToHtmlString()
    ))

我想让这项工作像这样。

 .DetailView(details => details.ClientTemplate(
            Html.Telerik().TabStrip()
                .Name("TabStrip_<#= PID #>")
                .SelectedIndex(0)
                .Items(items =>
                {
                    if(RxTpe == "New")
                    {
                        items.Add().Text("Details").LoadContentFrom("case1", "case1", new { id = "<#= PID #>" });
                     }
                     else
                     {
                         items.Add().Text("Details2").LoadContentFrom("case2", "case2", new { id = "<#= PID #>" });
                     }
                })
                .ToHtmlString()
    ))

任何人都可以帮助我,我该怎么做?

I am using Telerik Grid.

I have a situation I have to populate detail view based on a condition. Can anyone give me an idea, how can i switch it?

Here is my detail view code

 .DetailView(details => details.ClientTemplate(
            Html.Telerik().TabStrip()
                .Name("TabStrip_<#= PID #>")
                .SelectedIndex(0)
                .Items(items =>
                {
                items.Add().Text("Details").LoadContentFrom("PDetails", "Med", new { id = "<#= PID #>" });
               })
                .ToHtmlString()
    ))

I would like to make this work something like this.

 .DetailView(details => details.ClientTemplate(
            Html.Telerik().TabStrip()
                .Name("TabStrip_<#= PID #>")
                .SelectedIndex(0)
                .Items(items =>
                {
                    if(RxTpe == "New")
                    {
                        items.Add().Text("Details").LoadContentFrom("case1", "case1", new { id = "<#= PID #>" });
                     }
                     else
                     {
                         items.Add().Text("Details2").LoadContentFrom("case2", "case2", new { id = "<#= PID #>" });
                     }
                })
                .ToHtmlString()
    ))

Can any one help me, how can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳根太软 2024-12-20 05:18:23

定义“Items”集合时可以使用“if 语句”。

.Items(items =>
{
    if(RxTpe == "New")
    {
        items.Add().Text("Details").LoadContentFrom("case1", "case1", new { id = "<#= PID #>" });
    }
    else
    {
        items.Add().Text("Details2").LoadContentFrom("case2", "case2", new { id = "<#= PID #>" });
     }
 })

You can use "if statement" when you are defining the "Items" collection.

.Items(items =>
{
    if(RxTpe == "New")
    {
        items.Add().Text("Details").LoadContentFrom("case1", "case1", new { id = "<#= PID #>" });
    }
    else
    {
        items.Add().Text("Details2").LoadContentFrom("case2", "case2", new { id = "<#= PID #>" });
     }
 })
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文