插入项目后如何重新绑定 Telerik MVC 网格
我的 Telerik MVC 3 网格是通过 Ajax 填充的。插入一行后,我需要重新绑定网格。当我对 OnSave() 事件进行重新绑定时,数据重新绑定仍在控制器操作上发送。我需要类似 OnInserted 事件的东西。
有什么想法吗?
My Telerik MVC 3 grid is filled via Ajax. After inserting a row I need to rebind my grid. When I'm doing a rebind on the OnSave() event the data rebind is still sending on the Controller Action. I need something like an OnInserted event.
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用以下标准,
)
控制器代码
在 JavaScript 中使用以下代码
Use the following criteria,
)
Controller Code
In JavaScript use the following Code
执行插入代码后,您可以通过从控制器返回 GridModel 来重新绑定网格:
不要忘记使用
[GridAction]
装饰您的控制器。这假设您的网格有一个 ajax DataBinding 声明,如下所示:
You can rebind your grid by returning a GridModel from your controller after performing your insert code:
Don't forget to decorate your controller with
[GridAction]
.This assumes your grid has an ajax DataBinding declaration as follows:
这取决于您添加行的方式。如果您正在进行网格内编辑,网格应该会自动更新。如果您要从表单添加记录,则可以使用客户端 rebind() 方法刷新网格数据。
http:// /www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-client-api-and-events.html#rebind
It depends on how you're adding the row. The grid should update automatically if you're doing in-grid editing. If you're adding a record from a form, you can use the client-side rebind() method to refresh the grid data.
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-client-api-and-events.html#rebind
完成您的操作后,您可以致电:
jQuery("#gvPackage").data("t-grid").ajaxRequest()
On Complete Of Your Action you can call:
jQuery("#gvPackage").data("t-grid").ajaxRequest()