[英]How to get Telerik MVC Grid data
How can I pass asp.net mvc telerik grid data to controller using Ajax call. 如何使用Ajax调用将asp.net mvc telerik网格数据传递给控制器。 I need to save the telerik MVC grid data in database.
我需要将telerik MVC网格数据保存在数据库中。
var grid = $('#Grid').data('tGrid');
var data = grid.data;
I think this Telerik demo page with code should help you out. 我认为这个带代码的Telerik演示页面可以帮助你。
In the public partial class GridController : Controller
在
public partial class GridController : Controller
there are methods 有方法
public ActionResult EditingAjax
, public ActionResult EditingAjax
,
public ActionResult _SelectAjaxEditing()
, public ActionResult _SelectAjaxEditing()
,
public ActionResult _InsertAjaxEditing()
and public ActionResult _DeleteAjaxEditing
和
public ActionResult _DeleteAjaxEditing
Expanding on h3n's answer, to get at the actual grid data elements / cell values inside of each row of the Telerik grid, you would need code something along these lines: 扩展h3n的答案,为了获得Telerik网格每行内部的实际网格数据元素/单元格值,您需要沿着这些行的代码:
var grid = $('#Grid').data('tGrid');
var data = grid.data;
if(data != null) { // will be null if grid hasn't bound yet
var rowCount = data.length;
for(var i=0; i<rowCount; i++)
{
var myData = data[i].ColumnName;
doSomethingWith(myData);
}
}
You should be able to use Model binding on the controller just like you do on a regular form post. 您应该能够像在普通表单帖子上那样在控制器上使用模型绑定。 It will also pass the FormCollection object to the controller as well.
它也会将FormCollection对象传递给控制器。 I know this is late but hopefully this will help you.
我知道这已经很晚了,但希望这会对你有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.