From 802e9d21d45dcd1c709c0c8ce9ed91b33db59cae Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 23 May 2022 11:29:29 +0200 Subject: [PATCH] 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 Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- 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 9c5386a394..4851fa693c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -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))); }); -- 2.39.5