{hero}

column.index()

自:DataTables 1.10

在欄索引格式之間轉換。

描述

當使用 DOM 時,您通常會使用欄的**可見索引**,因為那是 DOM 中可用的資訊(當欄被 DataTables 隱藏時,它會完全從 DOM 中移除,以便在未來需要透過 column().visible() 重新顯示時再插入)。然而,當處理表格的原始資料時,您通常會想要使用**欄資料索引**。此方法用於在兩種格式之間轉換。

類型

function column.index( type, index )

描述

從輸入的欄索引類型轉換為所需的類型。

參數
返回

計算後的欄索引

範例

顯示關於點擊欄的欄索引資訊

var table = new DataTable('#myTable');

table.column(0).visible(false);

$('#example tbody').on('click', 'td', function () {
	var visIdx = $(this).index();
	var dataIdx = table.column.index('fromVisible', visIdx);

	alert('Column data index: ' + dataIdx + ', and visible index: ' + visIdx);
});