columns.orderDataType
起始版本:DataTables 1.10
即時 DOM 排序類型指定。
描述
DataTables 的主要排序方法(ordering
功能)使用記憶體中快取的資料,而不是每次執行排序時直接從 DOM 讀取資料,以提高效能(從 DOM 讀取資料本質上較慢)。然而,有時您實際上希望直接從 DOM 讀取,並知道效能會受到影響,例如當您的表格中有表單元素,而最終使用者可以變更值時。此組態選項提供外掛程式在 DataTables 中提供此功能。
請注意,DataTables 中沒有內建的 columns.orderDataType
外掛程式,它們必須單獨添加。有關詳細資訊,請參閱 DataTables 排序外掛程式頁面。
類型
此選項可以採用以下類型:
範例
使用 columnDefs
設定即時資料排序類型
new DataTable('#myTable', {
columnDefs: [
{ orderDataType: 'dom-text', targets: [2, 3] },
{ type: 'numeric', targets: 3 },
{ orderDataType: 'dom-select', targets: 4 },
{ orderDataType: 'dom-checkbox', targets: 5 }
]
});
使用 columns
設定即時資料排序類型
new DataTable('#myTable', {
columns: [
null,
null,
{ orderDataType: 'dom-text' },
{ orderDataType: 'dom-text', type: 'numeric' },
{ orderDataType: 'dom-select' },
{ orderDataType: 'dom-checkbox' }
]
});
相關
以下選項直接相關,並且可能在您的應用程式開發中也很有用。