From 4ff1c690cc4db88b9a2cbdad3a04db2b1f818fb1 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 12:33:01 +1100 Subject: [PATCH] Bug fix for paginated tables --- InvenTree/templates/js/tables.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/InvenTree/templates/js/tables.js b/InvenTree/templates/js/tables.js index f09c683bff..21e673d5ed 100644 --- a/InvenTree/templates/js/tables.js +++ b/InvenTree/templates/js/tables.js @@ -145,10 +145,7 @@ $.fn.inventreeTable = function(options) { var filters = options.queryParams || options.filters || {}; options.queryParams = function(params) { - for (var key in filters) { - params[key] = filters[key]; - } - + // Override the way that we ask the server to sort results // It seems bootstrap-table does not offer a "native" way to do this... if ('sort' in params) { @@ -170,6 +167,15 @@ $.fn.inventreeTable = function(options) { } + for (var key in filters) { + params[key] = filters[key]; + } + + // Add "order" back in (if it was originally specified by InvenTree) + // Annoyingly, "order" shadows some field names in InvenTree... + if ('order' in filters) { + params['order'] = filters['order']; + } return params; }