mvc中的telerik网格中的客户端模板

时间:2011-07-30 09:20:03

标签: asp.net asp.net-mvc

我在我的telerik网格中绑定了客户端模板,但它没有出现在我的专栏中为什么会发生这种情况我是否必须将其称为

视图

<%=Html.Telerik().Grid(Model).Name("Grid").DataKeys(keys => keys.Add(m => m.ResExpID))
  .Columns(columns =>
{
    columns.Bound(m => m.ResExpID).Width(100);
    columns.Bound(m => m.Company).Width(100);

    columns.Bound(m => m.Title).Width(200);
    columns.Bound(m=>m.Description).ClientTemplate(                             
                                Html.Telerik().DropDownList()
                                .Name("UserState<#= UserState #>")
                                .BindTo(new SelectList(us.GetUserNameByEmail("ghg").ToList()))
                                .Encode(false)
                                .ToHtmlString().Replace("{", "{{").Replace("}", "}}")).Encoded(false)

    .Title("User State");

           columns.Command(commands =&gt;             {

            commands.Edit().ButtonType(GridButtonType.Text);
            commands.Delete().ButtonType(GridButtonType.Text);

        }).Width(200).Title("Command");









})
 .ClientEvents(events => events.OnRowSelect("onRowSelected"))











    .DataBinding(dataBinding =>
    {


        dataBinding.Server()
          .Select("WorkExperience", "Editresume")

          .Update("_Saveexperience", "Editresume")


        .Delete("_Deleteexperience", "Editresume");

    })
    .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
    .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
    .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
    .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
    .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
    .Footer((bool)ViewData["showFooter"])
    .Editable(editing => editing.Mode(GridEditMode.PopUp))


    .RowAction(row => row.Selected = row.DataItem.ResExpID.Equals(ViewData["id"]))

    %>  

1 个答案:

答案 0 :(得分:1)

我有类似的问题。您可以查看可能对您有帮助的页面:

http://www.telerik.com/community/forums/aspnet-mvc/grid/client-template-not-displayed-with-mvc-grid.aspx

当您提供模型时,服务器上会发生绑定:

.Grid(Model).

并在客户端上发生绑定时应用客户端模板。最简单的解决方案是使用'Grid'构造函数的这个重载:

.Grid<Namespace.Module.Your.Type>().

然后应该出现客户端模板。