Telerik MVC Grid Razor中的DetailView

时间:2013-05-06 12:37:49

标签: asp.net-mvc-4 razor telerik-grid telerik-mvc detailview

以下是我正在使用的当前视图,我想向其添加DetailView。我已经尝试了很多例子,即使我使用了telerik演示代码,但是代码似乎都没有用。任何人都可以告诉我一些代码如何做到这一点。每个DetailView行都应填充"detailViewCategory",如模型

所示

查看

   @(Html.Telerik().Grid(Model.Mappings)        
                .Name("Grid")
                .Scrollable(c => c.Height("200px"))
                .Columns(columns =>
                {
                    columns.Bound(o => o.nopCategoryID).Hidden(true);
                    columns.Bound(o => o.nopCategory).Width(100).Title("Category");                               

                    columns.Bound(e => e.ClockCategory).Width(200).Title("Mapped To").Template(t => t.ClockCategory.Replace(",", "<br />")); 

                    columns.Bound(o => o.nopCategoryID)
                                        .Width(50)
                                        .Centered()
                                        .Template(o => Html.ActionLink("Edit", "EditProduct", new { id = o.nopCategoryID }))
                                        .Title("Edit");
                    columns.Bound(o => o.nopCategoryID)
                                        .Width(50)
                                        .Centered()
                                        .Template(o => Html.ActionLink("Delete", "DeleteMapping", new { id = o.nopCategoryID }))
                                        .Title("Delete");        
                })

                )

模型

    public class C_Category
    {
        public int nopCategoryID { get; set; }     
        public string nopCategory { get; set; }
        public string ClockCategory { get; set; }

        public DetailViewCategory detailViewCategory { get; set; }
    }

DetailViewCategory

public class DetailViewCategory
{
    public int nopCategoryID { get; set; }
    public int ClockCategoryID { get; set; }
    public string ClockCategory { get; set; }
}

1 个答案:

答案 0 :(得分:0)

.DetailView(details => details.ClientTemplate(

            Html.Telerik().TabStrip()
                .Name("TabStrip_<#= nopCategoryID#>")
                .SelectedIndex(0)
                .Items(items =>
                {
                    items.Add().Text("Details").LoadContentFrom("ActionName", "ControllerName", new { id = "<#= nopCategoryID#>"});
                })
                .ToHtmlString()
    ))