【问题标题】:Datatable fixed column width数据表固定列宽
【发布时间】:2020-11-20 20:05:05
【问题描述】:

您好,我正在使用数据表在我们的网站上显示一些数据,但由于某种原因,我无法将列宽固定为固定大小,它会自动计算列宽。 我尝试为列指定 {"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"
          },
    });

谁能指导我哪里出错了?

这是我得到的输出,基本上我需要缩小网站列。

【问题讨论】:

    标签: css datatables


    【解决方案1】:

    在 css 中试试这段代码:

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

    【讨论】:

      猜你喜欢
      • 2012-09-22
      • 1970-01-01
      • 2013-08-16
      • 2014-10-31
      • 2014-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多