2017-04-17 43 views
0

我有表。在DataTable中的row.add未顯示響應後

var mytable=$('#my-table').DataTable({options}); 

時生成的標記表...

<table class="table table-hover table-striped table-responsive dataTable no-footer" id="my-table" role="grid" aria-describedby="my-table_info"> 

我添加具有mytable.row.add({columns}); 行,當我加入新行,沒有顯示在響應火狐瀏覽器(表中鉻的顯示響應時刪除類來自標記表的'datatable')。

如果這是空的,則顯示正確。

爲什麼顯示錶格響應?

最好的方面。

回答

1

在您的表格前添加<div class="table-responsive"> div。並刪除,如果有任何width="100%"風格適用於您的表格。

<div class="table-responsive"> 
    <table id="example" class="table table-striped table-hover dt-responsive" cellspacing="0"> 
    <thead> 
     <tr> 
     <th>Name</th> 
     <th>Surname</th> 
     </tr> 
    </thead> 
    </table> 
</div> 
+0

我這樣做,但讓我滾動垂直和水平和表仍然寬,但不是頁面外。 –

+1

你可以請創建一個[jsFiddle](https://jsfiddle.net/)?沒有現場代碼很難說。 –

+0

我無法加載js文件,它們很複雜。 –

0

解決了。

我添加

$('#example').dataTable({ 
    "autoWidth": false 
}); 

鉻工作。

並設置列的寬度由CSS。這是在Firefox中工作。

該原因是列自動寬度給出值。