Bug 32030: Fix datatable.js order_by

Getting Uncaught (in promise) TypeError: order_by.split is not a function
Because data is an array: "data": ["me.package_id", "me.name"],

If we modify it with "data": "me.package_id:me.name",
(what we are using in other places) we are getting the following warning
when the table is init:
"Requested unknown parameter 'me.package_id:me.name' for row 0, column 0. For more information about this error"

Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-05-23 11:29:29 +02:00 committed by Tomas Cohen Arazi
parent 8e0f5fb3fe
commit 802e9d21d4
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 3 additions and 1 deletions

View File

@ -684,7 +684,9 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
order.forEach(function (e,i) {
var order_col = e.column;
var order_by = options.columns[order_col].data;
order_by = order_by.split(':');
if (!Array.isArray(order_by)) {
order_by = order_by.split(':');
}
var order_dir = e.dir == 'asc' ? '+' : '-';
Array.prototype.push.apply(orderArray,order_by.map(x => order_dir + (!x.includes('.')?'me.'+x:x)));
});