From b5e95c31cbd3153e2a0a136798a95dc56abb9cac 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 (cherry picked from commit 548562ca17ae06088e84d8fe9287a9f4043ce80e) Signed-off-by: Fridolin Somers (cherry picked from commit 2bbff47bcac044236a2b8c8bcf8b35b577f0fc21) Signed-off-by: Andrew Fuerste-Henry --- 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 53f300baf9..feedb5da58 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -586,13 +586,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