zoukankan      html  css  js  c++  java
  • Datatable 插入一行数据到第一行

    var t = $('#passwdHOST').DataTable({
        'searching': true,
        'ordering': false,
        'autoWidth': false,
        dom: 'Bfrtip',
        buttons: [{
            text: "导出到Execl",
            extend: 'excelHtml5',
            //className:'execl'
            //customize: function( xlsx ) {
            //	var sheet = xlsx.xl.worksheets['sheet1.xml'];
            //$('row c[r^="C"]', sheet).attr( 's', '2' );
            //}
        },{
                text: '新建主机',
                action: function ( e, dt, node, config ) {
                    //e:
                    // 触发事件的事件对象
                    //dt:
                    // 主机DataTable的DataTables API实例
                    //node
                    //单击的按钮节点的jQuery实例
                    //config
                    //按钮的配置对象
    
                        create_row(e, dt, node, config);
                }
            },{
                text: '删除主机',
                action: function ( e, dt, node, config ) {
                    //e:
                    // 触发事件的事件对象
                    //dt:
                    // 主机DataTable的DataTables API实例
                    //node
                    //单击的按钮节点的jQuery实例
                    //config
                    //按钮的配置对象
    
                        create_row(e, dt, node, config);
                }
            }
        ],
       
        language: {
            "decimal": "",
            "emptyTable": "数据正在加载中,请稍后...",
            "info": "显示 _START_ 到 _END_ 页共 _TOTAL_ 条",
            "infoEmpty": "显示 0 到 0 页共 0 条",
            "infoFiltered": "(filtered from _MAX_ total entries)",
            "infoPostFix": "",
            "thousands": ",",
            "lengthMenu": "显示 _MENU_ 条",
            "loadingRecords": "加载中...",
            "processing": "处理中...",
            "search": "搜索:",
            "zeroRecords": "没有匹配项",
            "paginate": {
                "first": "First",
                "last": "Last",
                "next": "下页",
                "previous": "上页"
            },
            "aria": {
                "sortAscending": ": activate to sort column ascending",
                "sortDescending": ": activate to sort column descending"
            },
        },
    
    });
    
    $.ajax({
                url: '/passwd/api/hosts',
                type: "POST",
                data: ajax_data,
                success: function (data) {
                     var rowNode = t.row.add(
                        [
                        data.id,
                        data.ip,
                        data.hostname,
                        data.os,
                        data.protocal,
                        data.port,
                        data.comments,
                        "<div class='btn-group'>" +
                        "<button  type='button' class='" + select + " btn " + btninfo + " '  data-target='#modal .bd-example-modal-lg '  >查看</button>" +
                        "<button type='button' class='btn btn-info dropdown-toggle' data-toggle='dropdown'>" +
                        "  <span class='caret'></span>" +
                        "</button>" +
                        "<ul class='dropdown-menu' role='menu'>" +
                        "  <li><a href='passwdLOG.html'>查看密码修改日志</a></li>" +
                        "</ul>" +
                        "<button  type='button' class='" + append + " btn " + btnsuccess + "'  data-target='#modal .bd-example-modal-lg'>增加</button>" +
                        "<button  type='button' class='" + modify + " btn " + btnwarning + "'  data-target='#modal .bd-example-modal-lg' >修改</button>" +
                        "<button  type='button' class='" + del + " btn " + btndanger + "'  data-target='#modal .bd-example-modal-lg' >删除</button>" +
                        "</div>"
                        ]
                    ).draw().node();
                    $(t.table().body()).prepend($(rowNode)) //  将新添加的一行插入到第一行
                    $( rowNode ).css( 'color', 'red' )  //修改新加一行的样式
    

      

  • 相关阅读:
    言多必失失在哪?
    C/C++四种方法实现加法操作_艾孜尔江撰
    VS Code添加到右键菜单_艾孜尔江撰
    网页端UVC相机测试_艾孜尔江撰
    Python爬虫示例
    Java制作软光栅化渲染器_艾孜尔江撰
    指针常量与常量指针
    C/C++中Main之后执行的函数_艾孜尔江撰
    Token机制 ——JSON Web Token(JWT)的详解
    Excel-实现隔行设置背景色
  • 原文地址:https://www.cnblogs.com/randomlee/p/10062768.html
Copyright © 2011-2022 走看看