Optimized DataTables fixedOrder handling (fixes #2235)

This commit is contained in:
Bernd Bestel 2023-05-17 22:44:42 +02:00
parent 778cf847d3
commit 631f03e62c
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 10 additions and 7 deletions

View File

@ -857,11 +857,14 @@ $.extend(true, $.fn.dataTable.defaults, {
api.rowGroup().dataSrc(rowGroup.dataSrc); api.rowGroup().dataSrc(rowGroup.dataSrc);
// Apply fixed order for group column // Apply fixed order for group column
var fixedOrder = { api.order.fixed({
pre: [rowGroup.dataSrc, 'asc'] pre: [rowGroup.dataSrc, 'asc']
}; });
}
api.order.fixed(fixedOrder); else
{
// Remove fixed order
api.order.fixed({});
} }
} }
} }
@ -1202,10 +1205,9 @@ $(document).on("click", ".change-table-columns-rowgroup-toggle", function()
dataTable.rowGroup().dataSrc(columnIndex); dataTable.rowGroup().dataSrc(columnIndex);
// Apply fixed order for group column // Apply fixed order for group column
var fixedOrder = { dataTable.order.fixed({
pre: [columnIndex, 'asc'] pre: [columnIndex, 'asc']
}; });
dataTable.order.fixed(fixedOrder);
} }
var settingKey = 'datatables_rowGroup_' + dataTable.settings()[0].sTableId; var settingKey = 'datatables_rowGroup_' + dataTable.settings()[0].sTableId;

View File

@ -1,5 +1,6 @@
var shoppingListTable = $('#shoppinglist-table').DataTable({ var shoppingListTable = $('#shoppinglist-table').DataTable({
'order': [[1, 'asc']], 'order': [[1, 'asc']],
"orderFixed": [[3, 'asc']],
'columnDefs': [ 'columnDefs': [
{ 'orderable': false, 'targets': 0 }, { 'orderable': false, 'targets': 0 },
{ 'searchable': false, "targets": 0 }, { 'searchable': false, "targets": 0 },