简体   繁体   English

MVC中Telerik网格中的客户端模板

[英]client template in telerik grid in mvc

i have bind the client template in my telerik grid but it does not appears in my column why does it happens does i have to call it 我已经在我的telerik网格中绑定了客户端模板,但是它没有出现在我的专栏中,为什么会发生,我必须调用它

view 视图

<%=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 => { columns.Command(commands => {

            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"]))

    %>  

I had a similar issue. 我有一个类似的问题。 You can check this page that will probably help you: 您可以检查此页面,这可能会帮助您:

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

What it says is the binding occurs on the server when you provide the model like you do: 它说的是,当您像提供模型一样,绑定发生在服务器上:

.Grid(Model).

and the client templates are applied when the binding occurs on the client. 当客户端上发生绑定时,将应用客户端模板。 The simplest solution would be to use this overload of the ' Grid ' constructor: 最简单的解决方案是使用Grid构造函数的以下重载:

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

then the client template should appear. 然后应显示客户端模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM