zoukankan      html  css  js  c++  java
  • datatables初始化用法

    var recordTable =
            $('#record_table').DataTable({
                "fnInitComplete": function () { //表格初始化完成后调用的回调方法
                    if ($('#record_table .dataTables_empty').length != 0) {
                        $('#record_table .odd').children().attr("colspan", 6);
                    }
                },
                bAutoWidth: false,
                "bStateSave": true,
                "aaSorting": [],
                "oLanguage": {
                    "sSearch": "搜索",
                    "sLengthMenu": "每页显示 _MENU_ 条记录",
                    "sZeroRecords": "没有记录",
                    "sInfo": "从 _START_ 到 _END_ /  共 _TOTAL_ 条",
                    "sInfoEmpty": "显示0条记录",
                    "oPaginate": {
                        "sPrevious": "上一页",
                        "sNext": "下一页"
                    }
                },
                select: {
                    style: 'multi'
                },
                destroy: true,//每次重新加载
                "aoColumns": [
                    { "sDefaultContent": '', "width": "5%", "bSortable": false, "sClass": "text-left" },
                    { "data": 'userName', "width": "19%", "bSortable": false, "sClass": "text-left" },
                    { "data": 'followTime', "width": "19%", "bSortable": false, "sClass": "text-left" },
                    {
                        "data": 'certClass', "width": "19%", "bSortable": false, "sClass": "text-left",
                        "render": function (data, type, full, meta) {
                            if (data == 0)
                                return '未认证';
                            else if (data == 1) return '普通认证';
                            else if (data == 2) return '高级认证';
                            else if (data == 5) return '认证未通过';
                        }
                    },
                    {
                        "data": 'followMethod', "width": "19%", "bSortable": false, "sClass": "text-left",
                        "render": function (data, type, full, meta) {
                            var newData = data.replace('1', '电话').replace('2', '短信').replace('3', '邮件').replace('4', '平台即时通讯');
                            return newData;
                        }
                    },
                    {
                        "data": 'followRemark', "width": "19%",
                        "bSortable": false,
                        "sClass": "text-left position",
                        "render": function (data, type, full, meta) {
                            if (data == null) data = "";
                            return '<div class="text-hidden ellipsis" >' + data + '</div> ';
                        }
                    }
                ],
                "columnDefs": [{
                    "searchable": false,
                    "orderable": false,
                    "targets": 0,
                }
                ]
                ,
                "bProcessing": true,
                "ajax": {
                    "url": '/EnterpriseUsers/GetEnterUsersFollowList',
                    "type": 'POST',
                    "data": { "enterNum": enterNum },
                    "dataSrc": function (json) {
                        if (!json.data) {
                            json.data = [];
                        }
                        return json.data;
                    }
                },
            });
        recordTable.on('order.dt search.dt', function () {
            recordTable.column(0, { search: 'applied', order: 'applied' }).nodes().each(function (cell, i) {
                cell.innerHTML = i + 1;
            });
        }).draw();


    更多资料查阅网址:http://datatables.club/example/#data_sources

  • 相关阅读:
    BZOJ 1391: [Ceoi2008]order
    BZOJ 4504: K个串
    2019 年百度之星·程序设计大赛
    POJ 2398 Toy Storage (二分 叉积)
    POJ 2318 TOYS (二分 叉积)
    HDU 6697 Closest Pair of Segments (计算几何 暴力)
    HDU 6695 Welcome Party (贪心)
    HDU 6693 Valentine's Day (概率)
    HDU 6590 Code (判断凸包相交)
    POJ 3805 Separate Points (判断凸包相交)
  • 原文地址:https://www.cnblogs.com/yeqrblog/p/8961367.html
Copyright © 2011-2022 走看看