数据表固定列宽

时间:2014-03-28 07:36:32

标签: css datatables

您好我正在使用数据表在我们的网站上显示一些数据,但有些原因我无法将列宽固定为固定大小,它会自动计算列宽。 我已经尝试为列指定{“sWidth”:“30px;”}但没有运气。 在这里,我给出了呈现表格的代码

    jQuery('#dynamic')
        .html('<table cellpadding="1" cellspacing="1" border="0" class="properties" id="settingsGrid"></table>');

    jQuery('#settingsGrid').dataTable({
//      "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "aaData":  aDataSet,
        "aoColumns": [
          {"sTitle":"catId", "bVisible": false},
          {"sTitle" : "Name","sWidth": "30px;"},
          {"sTitle" : "Email","sWidth": "30px;"},
          {"sTitle" : "Phone no","sWidth": "30px;"},
          {"sTitle" : "Location","sWidth": "30px;"},
          {"sTitle" : "No of Properties","sWidth": "30px;"},
          {"sTitle" : "Web Site URL","sWidth": "30px;"},
          {"sTitle" : "Created Date","sWidth": "30px;"}
          ],
          "aoColumnDefs": [ {
              "aTargets": [ 0 ],
              "mRender": function ( data, type, row ) {
                    return data +' '+ row[3];
              }
          }
          ],
          "bAutoWidth": false,
          "bDeferRender": true,
          "sScrollY": "350",
          "bScrollCollapse": true,
          "bFilter" : false,
          "bSort" : false,
          "bInfo" : false,
          "bLengthChange": false,
          "iDisplayLength": 10,
          "oLanguage": {
            "sEmptyTable": "No categories available in your name"
          },
          "oLanguage": {
              "sInfoEmpty": "No entries to show"
          },
    });

任何人都可以指导我出错的地方吗?

以下是我得到的输出,基本上我需要缩小网站列。enter image description here

1 个答案:

答案 0 :(得分:0)

在css中尝试这段代码:

 #settingsGrid td {
     width: 30px !important;
   }