Ajax 在网格、模板和 ClientTemplates 初始加载时无法工作
我有以下代码:
@using com.mycompany.myproject.web.ViewModels @model IEnumerable @{ Html.Telerik().Grid(Model) .Name("Deducciones") .Columns(columns => { columns.Bound(p => p.IdDeducciones).ClientTemplate(""); columns.Bound(p => p.FechaInscripcion).Width(50); columns.Bound(p => p.FechaFin).Width(400); }) .DataBinding(dataBinding => dataBinding //Ajax binding .Ajax() //The action method which will return JSON .Select("DeduccionesAjax", "Empleados", new { id = ViewBag.Id }) ) .Pageable(pager => pager.PageSize(2)) .Sortable() .Render(); }
网格渲染良好,但仅在我转到第 2 页时才使用客户端模板。在初始加载时它不使用它。 作为解决方法,我在 ClientTemplate 之后添加了 .Template(@
它适用于初始负载和之后的负载。然而,这似乎很奇怪,因为我见过的示例或文档都没有指定模板和客户端模板。
我是否遗漏了一些东西,使得第一个负载不是来自 Ajax 或类似的东西?
提前致谢。
I have the following code:
@using com.mycompany.myproject.web.ViewModels @model IEnumerable @{ Html.Telerik().Grid(Model) .Name("Deducciones") .Columns(columns => { columns.Bound(p => p.IdDeducciones).ClientTemplate(""); columns.Bound(p => p.FechaInscripcion).Width(50); columns.Bound(p => p.FechaFin).Width(400); }) .DataBinding(dataBinding => dataBinding //Ajax binding .Ajax() //The action method which will return JSON .Select("DeduccionesAjax", "Empleados", new { id = ViewBag.Id }) ) .Pageable(pager => pager.PageSize(2)) .Sortable() .Render(); }
The grid renders fine but only uses the client template when I go to page 2 for instance. On the initial load it doesn't use it.
As a workaround I added .Template(@<text><a href='#'>@item.IdDeducciones</a></text>);
after the ClientTemplate and now it works on both the initial load and afterwards. However this seems strange as none of the examples or docs I've seen specify both a Template and a ClientTemplate.
Is there something I'm missing that's making the first load not come from Ajax or something similar?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如我在 论坛主题 您在 Telerik 论坛中打开,这是预期的,记录。客户端模板仅在进行客户端绑定(例如ajax)时应用。模板在服务器绑定期间应用,例如:
As I replied in the forum thread which you opened in the Telerik forums this is expected and documented. Client templates apply only when doing client binding (such as ajax). Templates are applied during server binding such as :