{hero}

取消選取

自:Select 1.0.0 版本起

項目(列、欄或儲存格)已取消選取。
請注意 - 此屬性需要 DataTables 的 Select 擴充套件。

描述

每當在 DataTable 中取消選取項目(列、欄或儲存格)時,就會觸發此事件,並提供有關已取消選取的項目資訊。

請注意,基於效能考量,每次取消選取動作只會觸發單一事件。結果是,如果在單一動作中取消選取多個項目,則每個取消選取的項目不會收到自己的事件,而是將有關取消選取項目的資訊傳遞到陣列中。

此外,與所有 DataTables 發出的事件一樣,此事件會以 dt 命名空間觸發。因此,若要監聽此事件,您也必須使用 dt 命名空間,只需將 .dt 附加到您的事件名稱即可(當使用 on()one() 時,會自動執行此操作)。

類型

function function( e, dt, type, indexes )

參數

範例

當列取消選取時,從列取得資料

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

table.on('deselect', function (e, dt, type, indexes) {
	if (type === 'row') {
		var data = table
			.rows(indexes)
			.data()
			.pluck('id');

		// do something with the ID of the deselected items
	}
});

當項目取消選取時,移除自訂類別

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

table.on('deselect', function (e, dt, type, indexes) {
	table[type](indexes)
		.nodes()
		.to$()
		.removeClass('custom-selected');
});