我在下面调用 JQuery 工作正常,但 porID 参数未正确发送到控制器。Net 而不是得到“porID”是“amp; porID”。Chrome 网络看到了这一点...
jQuery
oTable = $('#lista_cbo').dataTable({
"bServerSide": true,
"sAjaxSource": '@Url.Action("ListaGenerica", "Home", new { aController = "CBO", porID = true } )',
"bProcessing": true,
"oSearch": {"sSearch": "" + id + ""},
"sPaginationType": "full_numbers",
"aoColumns": [
{ "mDataProp": "CBOID", "sTitle": "ID", "sWidth": "16px" },
{ "mDataProp": "Sigla", "sTitle": "Sigla", "sWidth": "64px" },
{ "mDataProp": "Tipo", "sTitle": "Tipo", "sWidth": "64px" },
{ "mDataProp": "Descricao", "sTitle": "Descrição" },
{ "mData": null, "bSortable": false, "fnRender": function (o) {return '<a class="icone_16x16_detalhe" href=/CBO/Detalhar/' + o.aData["CBOID"] + '>D</a>';}}
],
});
控制器 C#
[HandleError]
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult ListaGenerica(DataTables param, string aController, bool porID = false)
{
var iniciaRegistrosEm = param.iDisplayStart;
var totalRegistrosPorPagina = param.iDisplayLength;
var totalColunas = param.iColumns;
var result = ERP.Helpers.ListagemPadrao.ListaPadrao(
aController,
param.iDisplayStart,
param.iDisplayLength,
Request["mDataProp_" + param.iSortCol_0.ToString()],
param.sSortDir_0,
param.sSearch,
porID
);
return Json(new
{
sEcho = param.sEcho,
iDisplayStart = param.iDisplayStart,
iTotalRecords = result.TotalRegistros,
iTotalDisplayRecords = result.TotalRegistrosVisualizados,
aaData = result.Dados
}, JsonRequestBehavior.AllowGet);
}