Browse Source

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 <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Martin Renvoize 2 years ago
committed by Jonathan Druart
parent
commit
548562ca17
  1. 4
      koha-tmpl/intranet-tmpl/prog/js/datatables.js

4
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;

Loading…
Cancel
Save