responsive.recalc()
自:Responsive 1.0.1
在顯示變更後,重新計算 responsive 使用的寬度。
請注意 - 此屬性需要 DataTables 的 Responsive 擴充功能。
描述
如果表格在隱藏時初始化(即 display: none
),瀏覽器將不會計算欄位的寬度(因為未顯示的元素沒有寬度!)。因此,Responsive 對於在各種寬度下顯示哪些欄位的計算將在此情況下不正確。
為了解決這個問題,提供了此方法來觸發重新計算 Responsive 使用的欄位寬度。在表格可見後呼叫它,以使 Responsive 正確顯示。
值得注意的是,在許多方面,此方法與 columns.adjust()
類似,您可能會希望將兩者一起使用(請參閱下面的範例)。
類型
範例
在表格可見後,重新計算 responsive 的動作
var table = new DataTable('#myTable');
$('#example').css('display', 'table');
table.responsive.recalc();
使用 columns.adjust()
和 responsive.recalc()
new DataTable('#myTable').columns.adjust().responsive.recalc();