{hero}

colReorder.order()

自:ColReorder 1.2.0 起

取得 / 設定欄位順序。
請注意 - 此屬性需要 DataTables 的 ColReorder 擴充功能。

說明

此方法提供取得 DataTable 目前欄位順序以及設定新順序的功能。

此方法觸發的重新排序是立即性的,不需要重新繪製表格。

類型

function colReorder.order()

說明

取得目前的欄位順序。

回傳值

回傳欄位索引的陣列。給定的欄位索引為原始欄位索引,其新位置由回傳陣列中的位置定義。

function colReorder.order( order [, originalIndexes ] )

說明

設定欄位順序。

參數
回傳值

用於鏈接的 DataTables API 實例

範例

在按鈕點擊時反轉表格中的欄位順序

var table = new DataTable('#myTable', {
	colReorder: true
});

$('#reverse').click(function (e) {
	table.colReorder.order([5, 4, 3, 2, 1, 0]);
});

還原原始順序,無論已套用任何排序(透過將第二個參數傳遞為 true

var table = new DataTable('#myTable', {
	colReorder: true
});

$('#reverse').click(function (e) {
	table.colReorder.order([0, 1, 2, 3, 4, 5], true);
});