cells().indexes()
自:DataTables 1.10
取得所選取儲存格的索引資訊。
描述
DataTables 將列和欄的資料儲存在內部索引中,以便快速執行排序、搜尋等操作。有時候了解這些索引會很有用,因為它們可以用於 rows()
、columns()
和其他使用選取器的 API 方法中進行高效的選取。
此方法也提供了可見欄索引以及欄資料索引,因為欄可以動態地新增和移除。
從 cells()
選取方法傳回的結果集中,每個儲存格的資料結構為
{
"row": integer, // Row index
"column": integer, // Column data index
"columnVisible": integer // Column visible index
}
類型
範例
取得每個包含值 '21' 的儲存格的欄索引
var table = new DataTable('#myTable');
var columns = table
.cells(':contains("21")')
.indexes()
.pluck('column')
.sort()
.unique();
alert('Columns containing 21: ' + columns.join(', '));
相關
以下選項直接相關,也可能在您的應用程式開發中很有用。