2017-03-06 6 views
1

両方のテーブルで幅の問題が発生します。以下のコードを参照してください、同じページ上に複数のjqueryデータ型があり、幅の問題が発生します。 (Datatables v10.13)

<table id="tblMessages" class="table table-striped table-bordered full-width table-advance table-hover table-condensed fl" style="border-collapse:collapse !important;"> 
       <thead> 
        <tr> 
         <th style="cursor:pointer; width:20%">From</th> 
         <th style="cursor:pointer; width:60%">Subject</th> 
         <th style="cursor:pointer; width:20%">Date</th> 
        </tr> 
       </thead> 
       <tbody></tbody> 
      </table> 

そして、ここが第二のテーブルで、私は「列」のDataTableのプロパティが、運に幅を与えてみました

<table id="tblToDos" class="table table-striped table-bordered table-advance full_width table-hover table-condensed fl" style="border-collapse:collapse !important"> 
       <thead> 
        <tr> 
         <th style="width:5%"></th> 
         <th style="cursor:pointer; width:20%">From</th> 
         <th style="cursor:pointer; width:30%">Patient</th> 
         <th style="cursor:pointer; width:35%">Subject</th> 
         <th style="cursor:pointer; width:10%">Reminder Date</th> 
        </tr> 
       </thead> 

注意。

そして、2番目のテーブルのinitを削除してもうまくいきます。

+0

正確に列の幅に関する問題はありますか?問題のスクリーンショットを表示できますか?これらのテーブルは最初に表示されていますか?テーブルが最初に非表示の場合(タブ、アコーディオンセクション) –

+0

両方のテーブルは表示されますが、カラム幅は自動的に自動幅に設定されています。 – Kendy

+0

初期化中に['autoWidth'](https://datatables.net/reference/option/autoWidth)オプションを無効にし、カラム幅を指定してみてくださいusint [' columns.width'](https://datatables.net/reference/ option/columns.width)オプションです。 –

答えて

0

私は解決策を得ました。それは適切な解決策ではありませんが、以下のコードを使用してグリッドを再描画することでこの問題を解決できます。

$('#tblMessages').DataTable().columns.adjust().draw(); 

この行は、2番目のdatatableの初期化が完了した後に置いてください。

関連する問題