Optionally select which column gets grouped

- Allow grouping by numerical values
This commit is contained in:
Oliver Walters 2019-05-28 19:12:10 +10:00
parent e4acca2951
commit 7ac52d4d9f
3 changed files with 5 additions and 5 deletions

View File

@ -46,6 +46,7 @@
location_detail: true,
part_detail: true,
},
groupByField: 'location',
buttons: [
'#stock-options',
],

View File

@ -72,9 +72,9 @@
if (this.options.groupBy && this.options.groupByField !== '') {
if (1 || (this.options.sortName != this.options.groupByField)) {
if (this.options.sortName != this.options.groupByField) {
this.data.sort(function (a, b) {
return a[that.options.groupByField].localeCompare(b[that.options.groupByField]);
return a[that.options.groupByField] == b[that.options.groupByField];
});
}

View File

@ -385,8 +385,7 @@ function loadStockTable(table, options) {
pageSize: 25,
rememberOrder: true,
groupBy: true,
groupByField: 'part_name',
groupByFields: ['part_name', 'test'],
groupByField: options.groupByField || 'part',
groupByFormatter: function(field, id, data) {
if (field == 'Part') {
@ -404,7 +403,7 @@ function loadStockTable(table, options) {
stock += item.quantity;
});
return stock + ' <i>(' + data.length + ' items)</i>';
return stock;
} else if (field == 'Location') {
/* Determine how many locations */
var locations = [];