模型绑定新的Datatables 1.10参数 [英] Model binding new Datatables 1.10 parameters
本文介绍了模型绑定新的Datatables 1.10参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Datatables 1.10中,ajax服务器端参数从
In Datatables 1.10 the ajax server side parameters changed from
public class DataTableParamModel
{
public string sEcho{ get; set; }
public string sSearch{ get; set; }
public int iDisplayLength{ get; set; }
public int iDisplayStart{ get; set; }
public int iColumns{ get; set; }
public int iSortingCols{ get; set; }
public string sColumns{ get; set; }
}
to(API Here http://datatables.net/manual/server-side )
to (API Here http://datatables.net/manual/server-side)
columns[i][data]
columns[i][name]
columns[i][orderable]
columns[i][search][regex]
columns[i][search][value]
columns[i][searchable]
...
draw
length
order[i][column]
order[i][dir]
...
search[regex]
search[value]
start
有些很容易绑定
public class DataTableParamModel
{
public string draw { get; set; }
public int length{ get; set; }
public int start { get; set; }
}
但新的数组格式看起来很棘手。
But the new array format looks tricky.
新的参数格式的新模板是什么?
What is the new appropriate model to map the new parameter format?
推荐答案
使用旧的ajax参数选项,它使用旧参数发送到服务器。这是通过 $。fn.dataTable.ext.legacy.ajax = true;
完成的,所以现在我的代码变成了...
I changed my javascript to use the legacy ajax params option which uses the old parameters to send to the server. This is done through $.fn.dataTable.ext.legacy.ajax = true;
so now my code becomes something like...
$.fn.dataTable.ext.legacy.ajax = true;
var datatable = $('#data-table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "MyController/AjaxHandlerPaging",
"pageLength": 25,
"order": [[2, 'desc']],
"columns": []
});
这篇关于模型绑定新的Datatables 1.10参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文