asp.net-mvc-3 – 最初未显示Telerik MVC Grid ClientTemplate复
发布时间:2020-12-16 06:29:44 所属栏目:asp.Net 来源:网络整理
导读:我对这里的帖子有一个非常类似的问题: Telerik grid with checkbox – Checkbox not showing up when the grid initially paints 基本上,我有一个带有ClientTemplate列的telerik MVC3剃刀网格,该列包含一个复选框.当页面最初加载时,复选框不在那里 – 而是
我对这里的帖子有一个非常类似的问题:
Telerik grid with checkbox – Checkbox not showing up when the grid initially paints 基本上,我有一个带有ClientTemplate列的telerik MVC3剃刀网格,该列包含一个复选框.当页面最初加载时,复选框不在那里 – 而是我想要复选框的值.但是,当触发ajax(例如将列分组在一起)时,复选框显示没有问题. 我真的不明白我上面粘贴的线程的解决方案….所以也许这就是答案,我只是不知道如何调用网格的构造函数.这是我的代码: research.cshtml @(Html.Telerik().Grid(Model) .Name("Grid") .DataKeys(keys => keys.Add(m => m.MessageInformation.MessageGUID)) .DataBinding(databinding => databinding.Ajax() .Select("_ViewMessages","Results") .Update("_UpdateSelectedMessage","Results")) .Columns(columns => { columns.Bound(o => o.MessageInformation.MessageGUID) .ClientTemplate("<input type='checkbox' id='chkMessage' name='checkedRecords' value='<#= MessageInformation.MessageGUID #>' />") .Title("Check") .Width(50) .HtmlAttributes(new { style = "text-align:center" }); columns.Bound(o => o.MessageInformation.MessageGUID).Title("ID"); columns.Bound(o => o.MessageInformation.MessageReceivedDateTime).Title("Received Date").Format("{0:d}"); columns.Bound(o => o.MessageInformation.MessageReceivedDateTime).Title("Received Time").Format("{0:t}"); columns.Bound(o => o.MessageInformation.MedVAMessageTypeString).Title("Message Type"); columns.Bound(o => o.MessageStatus).Title("Status"); columns.Command(commands => commands.Edit().ButtonType(GridButtonType.Text)).Title("Edit"); }) .Editable(editing => editing.Mode(GridEditMode.PopUp)) .Scrollable(scrolling => scrolling.Enabled(true)) .Sortable(sorting => sorting.Enabled(true)) .Pageable(paging => paging.Enabled(true)) .Filterable(filtering => filtering.Enabled(true)) .Groupable(grouping => grouping.Enabled(true)) .Footer(true) ) ResultsController.cs [GridAction] public ActionResult Research() { ViewBag.Message = "Research"; return View(DataAccess.Get_Messages()); } [GridAction] public ActionResult _ViewMessages() { ViewBag.Message = "Research"; return View(new GridModel(DataAccess.Get_Messages())); } 解决方法
您最初绑定到服务器数据,因此您将需要服务器模板以及客户端模板:
@(Html.Telerik().Grid(Model) .Name("Grid") .DataKeys(keys => keys.Add(m => m.MessageInformation.MessageGUID)) .DataBinding(databinding => databinding.Ajax() .Select("_ViewMessages","Results")) .Columns(columns => { columns.Bound(o => o.MessageInformation.MessageGUID) .Template(mi => { %> <input type='checkbox' id='chkMessage' name='checkedRecords' value='<%= mi.MessageGUID %>' /> %> }) .ClientTemplate("<input type='checkbox' id='chkMessage' name='checkedRecords' value='<#= MessageInformation.MessageGUID #>' />") .Title("Check") .Width(50) .HtmlAttributes(new { style = "text-align:center" }); columns.Bound(o => o.MessageInformation.MessageGUID).Title("ID"); columns.Bound(o => o.MessageInformation.MessageReceivedDateTime).Title("Received Date").Format("{0:d}"); columns.Bound(o => o.MessageInformation.MessageReceivedDateTime).Title("Received Time").Format("{0:t}"); columns.Bound(o => o.MessageInformation.MedVAMessageTypeString).Title("Message Type"); columns.Bound(o => o.MessageStatus).Title("Status"); columns.Command(commands => commands.Edit().ButtonType(GridButtonType.Text)).Title("Edit"); }) .Editable(editing => editing.Mode(GridEditMode.PopUp)) .Scrollable(scrolling => scrolling.Enabled(true)) .Sortable(sorting => sorting.Enabled(true)) .Pageable(paging => paging.Enabled(true)) .Filterable(filtering => filtering.Enabled(true)) .Groupable(grouping => grouping.Enabled(true)) .Footer(true) ) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 存储库模式:好还是坏?
- asp.net-core – 在Asp.net Core中使用StyleCop
- 什么可能导致asp.net应用程序忘记用户?
- asp.net-mvc – 带有实体框架的MVC控制器的T4模板 – 主机的
- asp.net-web-api – HttpClient不报告从Web API返回的异常
- asp.net-mvc – 使用ASP.NET Identity 2.0 UserManagerFact
- 使用ASP.NET MVC3中的JavaScriptSerializer转义引号
- asp.net-mvc – 使用jQuery.get时可以指定相对URL吗?
- asp.net-mvc – Web API错误:’ObjectContent`1’类型无法
- asp.net-web-api – 在WebAPI中的TaskScheduler.Unobserved