【发布时间】:2015-01-19 16:09:29
【问题描述】:
我将datatable.js 与 MVC4 Web 应用程序一起使用。我尝试在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, },
],
});
}
但它总是显示为空。
【问题讨论】:
-
你能用请求的正文更新你的问题吗?
-
当然...对不起我的英语不好...
-
实际上我尝试在我的控制器操作中传递一个数组。我已经使用了 '$.makeArray' 但它不起作用。
-
如果您将
long[] TaxInvoiceIds更改为string[] TaxInvoiceIds甚至只是string TaxInvoiceIds,会发生什么? -
是的,当我将 'string[] ' 替换为 'string' 时它正在工作,但你的意思是不可能使用数组?
标签: c# jquery asp.net-mvc-3 datatables