• datatables:如何禁用一列的排序


    第一列是checkbox列,不需要排序,所以需要禁用掉。

    代码如下:

    var table = $('#example1').DataTable(
                {
                    'paging' : true,
                    'lengthChange' : false,
                    'searching' : false,
                    'ordering' : true,
                    'info' : true,
                    'autoWidth' : true,
                    "processing" : true,
                    "serverSide" : true,
                    "ajax" : {
                        url : appPath + "/school/list/",
                        dataSrc : 'list'
                    },
                    columns : [
                            {
                                "data" : null,
                                "render" : function(data, type, full, meta) {
                                    return '<input type="checkbox" value="'
                                            + full.schoolID + '" />';
                                }
                            }, {
                                data : 'schoolID',
                                "orderable" : false
                            }, {
                                data : 'schoolName'
                            }, {
                                data : 'state',
                                "render" : function(data, type, full, meta) {
                                    var state = '正常';
                                    if (data == 'unactived') {
                                        state = "未激活";
                                    }
                                    return state;
                                }
                            }, {
                                data : 'activeTime'
                            }, {
                                data : 'expireTime'
                            }, {
                                data : 'principalID'
                            }, {
                                data : 'adminID'
                            }, {
                                data : null
                            } ],
                    columnDefs : [ {
                        targets : 0,
                        "orderable" : false
                    } ],
                    "order" : [ [ 1, 'asc' ] ]
                });

    'ordering' : true,   打开排序功能,若为false,则所有列全部不可用。

    columnDefs : [ { targets : 0, "orderable" : false } ], "order" : [ [ 1, 'asc' ] ]  必须同时存在。

    在指定索引为0的列关闭排序时,必须同时指定要指定排序的列的,否则禁用排序无效。

  • 相关阅读:
    【转】ORACLE日期时间 等函数大全
    list_car()函数小记
    git代码提交流程
    windows连接ubuntu服务器方式
    win10专业版安装docker实战
    selenium来识别数字验证码
    web服务器、WSGI跟Flask(等框架)之间的关系
    pymysql的使用
    sql常用 语句总结
    sql语句insert into where 错误解析
  • 原文地址:https://www.cnblogs.com/huiy/p/9037732.html
Copyright © 2020-2023  润新知