2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

Parameters table fix (#4120) (#4121)

* Account for paginated or unpaginated results

* Fix data loading when paginated

- Server-side paginated data needs to be provided in the correct format
- Look at how the original data were provided by the server
- Perform a single data load operation at the end

(cherry picked from commit 717a6ba5d209a1d546a60aa7329f40222c6d4437)
This commit is contained in:
Oliver 2022-12-31 00:04:55 +11:00 committed by GitHub
parent 93b51db089
commit 44f26d8e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1333,7 +1333,8 @@ function loadParametricPartTable(table, options={}) {
uniqueId: 'pk', uniqueId: 'pk',
onLoadSuccess: function(response) { onLoadSuccess: function(response) {
var data = response.results; // Data may be returned paginated, in which case we preference response.results
var data = response.results || response;
for (var idx = 0; idx < data.length; idx++) { for (var idx = 0; idx < data.length; idx++) {
var row = data[idx]; var row = data[idx];
@ -1346,8 +1347,14 @@ function loadParametricPartTable(table, options={}) {
data[idx] = row; data[idx] = row;
} }
if (response.results) {
response.results = data;
} else {
response = data;
}
// Update the table // Update the table
$(table).bootstrapTable('load', data); $(table).bootstrapTable('load', response);
} }
}); });
} }