{hero}

responsive.index()

自版本:Responsive 1.0.3

li 詳細資訊元素中取得儲存格索引。
請注意 - 此屬性需要 DataTables 的 Responsive 擴充功能。

已棄用!

從 v2.0.2 開始,此功能已被棄用。此功能尚未排定移除時間,但不建議使用,應使用下面討論的替代方案。

從 DataTables 1.10.11 和 Responsive 2.0.2 開始,不再需要此方法從 Responsive 顯示中的節點取得儲存格索引,因為 cell() 方法將接受具有 dt-rowdt-column 資料屬性的 td 元素(現在由 Responsive 使用)。

範例

點擊時將類別名稱新增至資料的主機儲存格)

var table = $('#example').DataTable();

$('#example').on( 'click', 'li', function () {
	$( table.cell( this ).node() )
		.addClass( 'highlight' );
} );

說明

當使用 Responsive 的詳細資訊列時,通常會需要取得詳細資訊列中顯示的資料來自的儲存格、列或欄的參考。此方法提供此能力,返回一個可用作 cell-selector 的物件,配合 cell() 方法使用。

請注意,此方法要求預設渲染器用於 responsive.details.renderer。如果使用自訂方法,將無法取得計算索引所需之資訊。

類型

function responsive.index( li )

說明

li 詳細資訊元素計算儲存格索引

參數
返回

包含屬性 rowcolumn 的儲存格物件。此物件可用作 DataTables cell-selector

範例

點擊時將類別名稱新增至資料的主機儲存格

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

$('#example').on('click', 'li', function () {
	var cellIndx = table.responsive.index(this);

	$(table.cell(cellIndex).node()).addClass('highlight');
});