jquery数据表边界问题

时间:2013-12-30 15:20:10

标签: jquery datatable jquery-datatables

如何显示空单元格的边框?有些列是空白的,没有值,因此这些列不显示边框及其空白。请参阅下面的屏幕截图并建议。

还有两条边界线,如何使它成为边界之一?

HTML

<table border="1"  id="products1" style="width:750px" >   
        <thead>
            <tr>
                <th>End Date</th>
                <th>Modify Date</th>
                <th>Comments</th>
                <th>By Who</th>
               </tr>
        </thead>
        <tbody></tbody>
    </table>

JS

oTable = $("#products1").dataTable({
       "aaData": newarray, 
       "bProcessing": true,
       "bDeferRender": true,
       "bFilter": true,
       "bRetrieve": true,
       "bPaginate": true,
       "bJQueryUI": true,
       "iDisplayLength": 5,

       "sPaginationType": "two_button",
       "sDom": 'T<"clear">frtip',
        "aoColumns": [{"sWidth": "135px","sClass": "center","bSortable": true},{
            "sWidth": "145px","sClass": "center","bSortable": true},{
            "sWidth": "145px","sClass": "center","bSortable": true},{
            "sWidth": "20px","sClass": "center","bSortable": false}

            ],
        "aoColumnDefs": [{ "fnRender": function (o, val) {
            return o.aData[0];
        },
            "sClass": "end date","aTargets": [0]
    }, {
        "fnRender": function (o, val) {

            return o.aData[1];
        },
            "sClass": "modified date","aTargets": [1]
    }, {
    "fnRender": function (o, val) {

            return o.aData[2];
        },
            "sClass": "comments","aTargets": [2]
    },{
    "fnRender": function (o, val) {

            return o.aData[3];
        },
            "sClass": "By who","aTargets": [3]
    }
    ]

});

2 个答案:

答案 0 :(得分:2)

提供的示例不正确,HTML&amp;中的表名称JS不匹配,请提供一个示例数组“aaData”:newarray ,用于复制您的确切问题。

当我使用自己的样本数组时,它工作正常,

oTable = $("#products1").dataTable({
    "aaData": [
        ["2013-01-01", "2013-01-01", "", "user1"],
        ["2013-01-01", "2013-01-01", "", "user1"],
        ["2013-01-01", "2013-01-01", "hello", "user1"]
     ]

对于第二个问题,请使用CSS属性 - border-collapse:collapse

<table border="1" id="products1" style="width: 750px;border-collapse: collapse">

答案 1 :(得分:0)

您必须为空单元格添加<td />。你不能只丢弃标签。