datatable.js fnServerParams 不处理参数化数组数据
datatable.js fnServerParams is not working with parameterized array data
我正在使用 datatable.js
和 MVC4 网络应用程序。我尝试在 fnServerParams
中传递数组数据。
这里我创建了一个名为 array
的数组对象来将数据传递到服务器端。
请看下面我的代码:
function GetTaxInvoices(IsInital, TaxInvoiceIds) {
alert("message : IsInital :- " + IsInital + " , TaxInvoiceIds :- " + TaxInvoiceIds);
var elementName = "#tblCreatedTaxInvoices";
ClearData(dtTable2);
var array = [51, 52];
ajaxUrl = (IsInital) ? null : '@Url.Action("GetCreatedTaxInvoices", "Invoice")';
dtTable2 = $(elementName).dataTable({
bProcessing: true,
bLengthChange: false,
sAjaxSource: ajaxUrl,
traditional: true,
"fnServerParams": function (aoData) {
aoData.push(
{ "name": "TaxInvoiceIds", "value": array }
);
},
aoColumns: [
{ sTitle: "Id", bSortable: false, bVisible: false, },
{ sTitle: "PoBox Number", bSortable: false, },
{ sTitle: "Email", bSortable: false, },
{ sTitle: "Owner", bSortable: false, },
{ sTitle: "General Tax", bSortable: false, },
{ sTitle: "Consumption Tax", bSortable: false, },
{ sTitle: "Due Amount", bSortable: false, },
{ sTitle: "Date", bSortable: false, },
{ sTitle: "Detailes", bSortable: false, },
],
});
}
但是总是显示null。
试试这个:
aoData.push(
{ "name": "TaxInvoiceIds[]", "value": array }
);
https://github.com/DataTables/DataTablesSrc/commit/a3f57e4
或者这个:
http://www.justinmichaels.net/custom-serverside-filtering-with-jquery-datables-and-asp-net-mvc3(我就是这样用的)
我正在使用 datatable.js
和 MVC4 网络应用程序。我尝试在 fnServerParams
中传递数组数据。
这里我创建了一个名为 array
的数组对象来将数据传递到服务器端。
请看下面我的代码:
function GetTaxInvoices(IsInital, TaxInvoiceIds) {
alert("message : IsInital :- " + IsInital + " , TaxInvoiceIds :- " + TaxInvoiceIds);
var elementName = "#tblCreatedTaxInvoices";
ClearData(dtTable2);
var array = [51, 52];
ajaxUrl = (IsInital) ? null : '@Url.Action("GetCreatedTaxInvoices", "Invoice")';
dtTable2 = $(elementName).dataTable({
bProcessing: true,
bLengthChange: false,
sAjaxSource: ajaxUrl,
traditional: true,
"fnServerParams": function (aoData) {
aoData.push(
{ "name": "TaxInvoiceIds", "value": array }
);
},
aoColumns: [
{ sTitle: "Id", bSortable: false, bVisible: false, },
{ sTitle: "PoBox Number", bSortable: false, },
{ sTitle: "Email", bSortable: false, },
{ sTitle: "Owner", bSortable: false, },
{ sTitle: "General Tax", bSortable: false, },
{ sTitle: "Consumption Tax", bSortable: false, },
{ sTitle: "Due Amount", bSortable: false, },
{ sTitle: "Date", bSortable: false, },
{ sTitle: "Detailes", bSortable: false, },
],
});
}
但是总是显示null。
试试这个:
aoData.push(
{ "name": "TaxInvoiceIds[]", "value": array }
);
https://github.com/DataTables/DataTablesSrc/commit/a3f57e4
或者这个: http://www.justinmichaels.net/custom-serverside-filtering-with-jquery-datables-and-asp-net-mvc3(我就是这样用的)