如何将值从控制器传递到jQuery数据表 [英] How to pass value from controller to jquery datatable
问题描述
我的数据表脚本代码是:
My datatable scripting code is:
$('#datatable').dataTable({
"processing": true,
"bServerSide": true,
"sAjaxSource": "/Employee/AjaxHandler",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "start", "value": something } );
}
这将在控制器中调用方法AjaxHandler:
and this is calling the method AjaxHandler in controller:
public ActionResult AjaxHandler(JQueryDataTableParamModel param,int start)
{
...
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = count,
iTotalDisplayRecords = count,
aaData = result
},
JsonRequestBehavior.AllowGet);
}
我想从AjaxHandler方法返回一个具有值的变量,该值将分配给该属性 在分页/排序/过滤期间再次调用时,aoData.push()中的值"将被分配给AjaxHandler方法中名为"start"的参数.
I want to return a variable with a value from AjaxHandler method that will be assigned to the property "value" inside aoData.push() that will be assigned to the parameter named "start" in the AjaxHandler method when called again during paging/sorting/filtering.How can I do that
推荐答案
请参阅以下链接 http://www.codeproject.com /Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part
这是关于如何实现创建ajax jquery数据表目标的相当完整的分步指南
this is quite a complete step by step guide on how you can achieve the goal to create ajax jquery datatable
这篇关于如何将值从控制器传递到jQuery数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!