div
自:DataTables 2.1
文字/HTML 容器。
描述
此功能本身不提供表格控制或資訊,而是提供一個簡單的機制,您可以使用它在 DataTables 控制的佈局網格中的表格周圍放置 HTML 或文字。
範例
在表格頂部顯示文字
new DataTable('#myTable', {
layout: {
top: {
div: {
text: 'This is my DataTable!'
}
}
}
});
使用 id 和 class 設定文字
new DataTable('#myTable', {
layout: {
topStart: {
div: {
className: 'warn',
id: 'warn-btn',
html: 'Click button to acknowledge: <button>Ack</button>'
}
}
}
});
使用選擇器在初始化後新增文字
let table = new DataTable('#myTable', {
layout: {
top: {
div: {
id: 'dynamic'
}
}
}
});
// Wait for the table to be ready - allows this to work with DOM or Ajax loaded data
table.ready(() => {
let el = document.querySelect('#dynamic');
el.textContent = 'Dynamically updated';
});
相關
以下選項直接相關,可能對您的應用程式開發也有用。