模型绑定新数据表 1.10 参数 [英] Model binding new Datatables 1.10 parameters

查看:36
本文介绍了模型绑定新数据表 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; }
}

到(此处的 API 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?

推荐答案

我更改了我的 javascript 以使用旧的 ajax params 选项,该选项使用旧参数发送到服务器.这是通过 $.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": []
});

这篇关于模型绑定新数据表 1.10 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆