mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 03:30:54 +00:00
* 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 717a6ba5d2
)
This commit is contained in:
@ -1333,7 +1333,8 @@ function loadParametricPartTable(table, options={}) {
|
||||
uniqueId: 'pk',
|
||||
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++) {
|
||||
var row = data[idx];
|
||||
@ -1346,8 +1347,14 @@ function loadParametricPartTable(table, options={}) {
|
||||
data[idx] = row;
|
||||
}
|
||||
|
||||
if (response.results) {
|
||||
response.results = data;
|
||||
} else {
|
||||
response = data;
|
||||
}
|
||||
|
||||
// Update the table
|
||||
$(table).bootstrapTable('load', data);
|
||||
$(table).bootstrapTable('load', response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user