我尝试在mvc应用程序中使用Datatable。我有一个自定义表单来过滤值,并通过ajax将数据加载到表中。
$('#tblProducts').DataTable({
serverSide: true,
bFilter: false,
"oLanguage": {
"sUrl": "/Content/DataTables/languages/Russian.json"
},
"ajax": function (data, callback, settings) {
$.ajax({
url: "/Admin/Product/Products",
type: "POST",
data: $("#searchForm").serializeObject() + "&draw=" + data.draw + "&start=" + data.start + "&length=" + data.length
});
}
});
在控制器中,我将我的viewmodel传递给过滤值和分页信息。 但我的桌子没有显示任何内容。
控制器
public ActionResult Products(ProductSearchViewModel model, int draw, int start, int length){//filtering data...}
JSON
${"draw":1,"iTotalRecords":1048,"iTotalDisplayRecords":10,"aaData":[["1","1001F","GoodWill","Воздушные","16","0,0008","0,87","False"],["2","1002F","GoodWill","Тормозные колодки","16","0,000928","1,505","False"],["3","1003F","GoodWill","Тормозные колодки","10","0,001716","1,595","True"],["4","1004F","GoodWill","Тормозные колодки","16","0,0008","1,88","True"],["5","1007F","GoodWill","Тормозные колодки","13","0,001804","2,46","True"],["6","1008F","GoodWill","Тормозные колодки","10","0,001716","1,6","True"],["7","1010F","GoodWill","Тормозные колодки","16","0,00096","1,63","True"],["8","1012F","GoodWill","Тормозные колодки","16","0,001494","0,023902","True"],["9","1013F","GoodWill","Тормозные колодки","16","0,0008","0,92","True"],["10","1013FX","GoodWill","Тормозные колодки","16","0,0008","0,93","True"]]}
这个json来到客户端,我可以在小提琴手中看到它,但是表格没有显示任何内容。 并且Chrome控制台中没有javascript错误。 如何在表格中显示数据?