From 548562ca17ae06088e84d8fe9287a9f4043ce80e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 2 Mar 2021 10:36:06 +0000 Subject: [PATCH] Bug 27807: Add multi-column ordering support to datatables wrapper This patch add mutli-column ordering support to the datatables api wrapper. Test plan 1/ Add a series of cities to the system with various combinations of city and state such that you can distinguish sorting on city + state in city ascending + state ascending, city ascending + state descending etc. 2/ Attempt to sort on the two fields in the table (Click the 'City' heading to sort on city name, then Shift Click on 'State' to add 'state' ordering on top.. Shift click again on state to reverse the 'state' ordering but maintain the 'City' ordering. 3/ Confirm the various ordering comes out correctly. 4/ Signoff Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 1b1a719141..25373b9306 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -634,13 +634,15 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { if(options.columns) { var order = data.order; + var orderArray = new Array(); order.forEach(function (e,i) { var order_col = e.column; var order_by = options.columns[order_col].data; order_by = order_by.split(':'); var order_dir = e.dir == 'asc' ? '+' : '-'; - dataSet._order_by = order_by.map(x => order_dir + (!x.includes('.')?'me.'+x:x)).join(','); + orderArray.push(order_by.map(x => order_dir + (!x.includes('.')?'me.'+x:x)).join(',')); }); + dataSet._order_by = orderArray.join(','); } return dataSet; -- 2.39.5