From 631f03e62c6c884eec0b63025c36ee3b9817274c Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 17 May 2023 22:44:42 +0200 Subject: [PATCH] Optimized DataTables fixedOrder handling (fixes #2235) --- public/js/grocy.js | 16 +++++++++------- public/viewjs/shoppinglist.js | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/public/js/grocy.js b/public/js/grocy.js index 3b845953..0aeff851 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -857,11 +857,14 @@ $.extend(true, $.fn.dataTable.defaults, { api.rowGroup().dataSrc(rowGroup.dataSrc); // Apply fixed order for group column - var fixedOrder = { + api.order.fixed({ 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); // Apply fixed order for group column - var fixedOrder = { + dataTable.order.fixed({ pre: [columnIndex, 'asc'] - }; - dataTable.order.fixed(fixedOrder); + }); } var settingKey = 'datatables_rowGroup_' + dataTable.settings()[0].sTableId; diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 8afa2b08..67c0cec9 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -1,5 +1,6 @@ var shoppingListTable = $('#shoppinglist-table').DataTable({ 'order': [[1, 'asc']], + "orderFixed": [[3, 'asc']], 'columnDefs': [ { 'orderable': false, 'targets': 0 }, { 'searchable': false, "targets": 0 },