info.callback
自:DataTables 2.0 起
資訊顯示回呼。
描述
此選項可用於自訂 info
功能所顯示的文字,包括完全取代產生的文字或根據需要自訂。這也可用於在表格分頁更改時收到通知,儘管在大多數情況下,info
和 page
事件會更適合。
舊版 infoCallback
選項是此選項的別名,適用於表格顯示的所有資訊。
類型
範例
使用回呼函式自訂顯示
new DataTable('#myTable', {
layout: {
bottomStart: {
info: {
callback: function (s, start, end, max, total, result) {
return `${start} to ${end} rows are shown, of ${max}`;
}
}
}
}
});
在回呼中使用 API 來顯示頁數
new DataTable('#myTable', {
layout: {
bottomStart: {
info: {
callback: function (s, start, end, max, total, result) {
let api = this.api();
let pageInfo = api.page.info();
return 'Page ' + (pageInfo.page + 1) + ' of ' + pageInfo.pages;
}
}
}
}
});
相關
以下選項直接相關,並且在您的應用程式開發中可能也很有用。