dataTables.js 禁止部分列排序

$(’#jk_table .tests’).DataTable({
“ordering”:true,
“order”: [], // 特殊。禁止第一列排序
“columnDefs”: [
{ “orderable”: false, “targets”: [1,4] }, // 禁止第2,5列排序
// { “orderable”: false, “targets”: 0 }, // 禁止第1列排序,不起效果
// { “orderable”: false, “targets”: 4 } // 禁止第5列排序
],
“destroy”: true,
“paging”: false,
“bInfo”: false,
“searching”: false
});

其他配置说明:
“bLengthChange”: false, //改变每页显示数据数量
“bFilter”: false, //过滤功能
“bProcessing”: true, //开启读取服务器数据时显示正在加载中……特别是大数据量的时候,开启此功能比较好
“bServerSide”: true, //开启服务器模式,使用服务器端处理配置datatable。注意:sAjaxSource参数也必须被给予为了给datatable源代码来获取所需的数据对于每个画。 这个翻译有点别扭。
“iDisplayLength”: 10,//每页显示10条数据
//ajax地址
“sAjaxSource”: “/Home/Home/GetUserList”,// get地址
//“sAjaxSource”: “/Home/Home/UserListPost”,// post地址
“fnServerData”: retrieveData,//执行方法

//默认排序
"order": [
    [0, 'asc'],//第一列正序
    [0, 'desc'],//第一列逆序
],
"lengthMenu": [
    [5, 15, 20, -1],
    [5, 15, 20, "All"] // change per page values here
],
// set the initial value
"pageLength": 10,
//向服务器传额外的参数
"fnServerParams": function (aoData) {
    aoData.push(
        { "name": "UserName", "value": $('#txt_UserName').val() },//员工名字
        { "name": "Division", "value": $('#Sel_Division').val() })//所处Division
},
//配置列要显示的数据
"columns": [
{ "data": "User_ID" },
{ "data": "User_Ename" },
{ "data": "AD_Account" },
{ "data": "User_Email" },
{ "data": "Division" },
{ "data": "Entity" },
 { "data": "IsValid" },
{ "data": "" }//操作按钮列
],
//按钮列
"columnDefs": [
    //{
//    "targets": -2,//编辑
//    "data": null,
//    "defaultContent": "<button id='editrow' class='btn btn-primary' type='button'><i class='fa fa-edit'></i></button>"
//},
{
    "targets": -1,//删除
    "data": null,
    "defaultContent": "<button id='editrow' class='btn btn-primary' type='button'><i class='fa fa-edit'></i></button><button id='delrow' class='btn btn-primary' type='button'><i class='fa fa-trash-o'></i></button>"
}
] ,
//语言配置--页面显示的文字
"language": {
    "aria": {
        "sortAscending": ": activate to sort column ascending",
        "sortDescending": ": activate to sort column descending"
    },
    "emptyTable": "No data available in table",
    "info": "Showing _START_ to _END_ of _TOTAL_ entries",
    "infoEmpty": "No entries found",
    "infoFiltered": "(filtered1 from _MAX_ total entries)",
    "lengthMenu": "Show _MENU_ entries",
    "search": "Search:",
    "zeroRecords": "No matching records found"
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值