multiple sort criteria #235

This commit is contained in:
Jan Prochazka
2022-06-09 13:12:31 +02:00
parent a92bd1c840
commit 94788454a9
4 changed files with 52 additions and 3 deletions

View File

@@ -372,6 +372,22 @@ export abstract class GridDisplay {
this.reload();
}
addToSort(uniqueName, order) {
this.setConfig(cfg => ({
...cfg,
sort: [...(cfg.sort || []), { uniqueName, order }],
}));
this.reload();
}
clearSort() {
this.setConfig(cfg => ({
...cfg,
sort: [],
}));
this.reload();
}
setGrouping(uniqueName, groupFunc: GroupFunc) {
this.setConfig(cfg => ({
...cfg,
@@ -408,6 +424,15 @@ export abstract class GridDisplay {
return this.config.sort.find(x => x.uniqueName == uniqueName)?.order;
}
getSortOrderIndex(uniqueName) {
if (this.config.sort.length <= 1) return -1;
return _.findIndex(this.config.sort, x => x.uniqueName == uniqueName);
}
isSortDefined() {
return (this.config.sort || []).length > 0;
}
get filterCount() {
return _.compact(_.values(this.config.filters)).length;
}