Reputation: 717
I am calling JQuery below that is working perfectly, but porID parameter is not sent correctly to the controller. Net instead of getting "porID" is "amp; porID". This was seen by the Network of 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>';}}
],
});
Controller 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);
}
Upvotes: 2
Views: 809
Reputation: 12705
looks nothing wrong with your code and assuming a get request your url should be something like this
Home/ListaGenerica/?acontroller=CBO&porId=true
which is correct and here because porId is a part of querystring &before its name is OK
Upvotes: 0
Reputation: 3267
Wrap @Url.Action with @Html.Raw:
@Html.Raw(Url.Action("ListaGenerica", "Home", new { aController = "CBO", porID = true } ))
java script probably is messing with '&' sign.
Upvotes: 3