鍍金池/ 問(wèn)答/HTML5  HTML/ dataTable 怎么控制tr寬度,如何設(shè)置

dataTable 怎么控制tr寬度,如何設(shè)置

g_simpool_vom_table = $('#' + simpool_vom_table_id).DataTable({
        "language": {
            "lengthMenu": "每頁(yè) _MENU_",
            "zeroRecords": "沒(méi)有找到記錄",
            "info": "第 _PAGE_ 頁(yè) (總共 _PAGES_ 頁(yè) )",
            "infoEmpty": "無(wú)記錄",
            "infoFiltered": "(從 _MAX_ 條記錄過(guò)濾)",
            "sSearch": "搜索",
            "oPaginate": {
                "sFirst": "第一頁(yè)",
                "sPrevious": " 上一頁(yè) ",
                "sNext": " 下一頁(yè) ",
                "sLast": " 最后一頁(yè) "
            }
        },
        "destroy": true,
        "paging": true,
        "pagingType": "simple_numbers", // simple, numbers, simple_numbers, full, full_numbers, first_last_numbers
        "lengthMenu": [5, 10, 20, 50, 100],
        "pageLength": 10,
        "lengthChange": true,
        "searching": true,
        "ordering": true,
        "info": true,
        "select": 'single',
        "autoWidth": true,
        "deferRender": true, // 延遲渲染,加速界面加載.
        "fixedHeader": true,
        "scrollX": false,
        "scrollY": false,
        "scrollCollapse": true,
        "stripeClasses": ['odd', 'even'],
        "dom": '<"row"<"col-lg-1"<"toolbar">><"col-lg-4"B><"col-lg-7"f>>t<"row"<"col-lg-2"l><"col-lg-3"i><"col-lg-7"p>>',
        //          "dom": '<"row"<"col-lg-4"B><"col-lg-8"f>>t<"row"<"col-lg-2"l><"col-lg-3"i><"col-lg-7"p>>', 
        "buttons": {
            // 'copy', 'csv', 'excel', 'pdf', 'print'
            "buttons": [{
                    extend: 'copy',
                    text: '<i class="fa fa-qrcode"></i>',
                    className: 'btn btn-warning btn-flat'
                },
                {
                    extend: 'csv',
                    text: '<i class="fa fa-file-excel-o"></i>',
                    className: 'btn btn-warning btn-flat',
                    title: 'Mote Lists-' + new Date()
                },
                {
                    extend: 'print',
                    text: '<i class="fa fa-print"></i>',
                    className: 'btn btn-warning btn-flat',
                    title: 'Mote Lists-' + new Date()
                }
            ]
        },
        "aoColumns": columnDefines,
        "ajax": {
            url: ajaxUrl,
            data: ajaxPara,
            dataType: 'json',
            type: "POST",
            dataSrc: '' //""=[],即普通Arr,  datarow:{"datarow": []} 
        }
    });
    //toolbar
    $("#simpool_vom_table_pdiv div.toolbar").html(getSimPoolVomTabToolBar());
    //創(chuàng)建
    $("#btn_flow_add").unbind("click");
    $("#btn_flow_add").on("click", function() {
        btn_flow_add_click();
    });

情況如圖
圖片描述

回答
編輯回答
神曲

tr寬度?td的寬度吧?
兩個(gè)配置項(xiàng):

$('#example').dataTable( {
  "autoWidth": false,
  "columns": [
    { "width": "20%" },
    null,
    null,
    null,
    null,
    null
  ]
} );

參考API:autowidth、columns.width

2017年11月20日 21:10