grid sorting

This commit is contained in:
Jan Prochazka
2020-04-04 11:06:27 +02:00
parent a3e9ba61af
commit 7b8a604957
7 changed files with 57 additions and 6 deletions

View File

@@ -307,6 +307,20 @@ export abstract class GridDisplay {
}
}
applySortOnSelect(select: Select, displayedColumnInfo: DisplayedColumnInfo) {
if (this.config.sort?.length > 0) {
select.orderBy = this.config.sort
.map(col => ({ ...col, dispInfo: displayedColumnInfo[col.uniqueName] }))
.filter(col => col.dispInfo)
.map(col => ({
exprType: 'column',
columnName: col.dispInfo.columnName,
direction: col.order,
source: { alias: col.dispInfo.sourceAlias },
}));
}
}
getDisplayColumns(table: TableInfo, parentPath: string[]) {
return (
table?.columns
@@ -350,6 +364,18 @@ export abstract class GridDisplay {
this.reload();
}
setSort(uniqueName, order) {
this.setConfig({
...this.config,
sort: [{ uniqueName, order }],
});
this.reload();
}
getSortOrder(uniqueName) {
return this.config.sort.find(x => x.uniqueName == uniqueName)?.order;
}
get filterCount() {
return _.compact(_.values(this.config.filters)).length;
}