custom grid display fix

This commit is contained in:
Jan Prochazka 2024-07-10 15:53:26 +02:00
parent befada8b87
commit cb0a11fda9
3 changed files with 15 additions and 7 deletions

View File

@ -20,6 +20,8 @@ export interface CustomGridColumn {
}
export class CustomGridDisplay extends GridDisplay {
customColumns: CustomGridColumn[];
constructor(
public tableName: NamedObjectInfo,
columns: CustomGridColumn[],
@ -35,6 +37,8 @@ export class CustomGridDisplay extends GridDisplay {
) {
super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
this.customColumns = columns;
this.columns = columns.map(col => ({
columnName: col.columnName,
headerText: col.columnLabel,
@ -63,12 +67,15 @@ export class CustomGridDisplay extends GridDisplay {
createSelect(options = {}) {
const select = this.createSelectBase(
this.tableName,
[],
// @ts-ignore
this.columns.map(col => ({
columnName: col.columnName,
})),
options
// this.columns.map(col => ({
// columnName: col.columnName,
// })),
options,
this.customColumns.find(x => x.isPrimaryKey)?.columnName
);
select.selectAll = true;
if (this.additionalcondition) {
if (select.where) {
select.where = {

View File

@ -554,9 +554,9 @@ export abstract class GridDisplay {
};
}
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options) {
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options, defaultOrderColumnName?: string) {
if (!columns) return null;
const orderColumnName = columns[0].columnName;
const orderColumnName = defaultOrderColumnName ?? columns[0]?.columnName;
const select: Select = {
commandType: 'select',
from: {
@ -732,6 +732,7 @@ export abstract class GridDisplay {
alias: 'count',
},
];
select.selectAll = false;
}
return select;
// const sql = treeToSql(this.driver, select, dumpSqlSelect);

View File

@ -15,7 +15,7 @@ export function dumpSqlSelect(dmp: SqlDumper, cmd: Select) {
if (cmd.selectAll) {
dmp.put('* ');
}
if (cmd.columns) {
if (cmd.columns && cmd.columns.length > 0) {
if (cmd.selectAll) dmp.put('&n,');
dmp.put('&>&n');
dmp.putCollection(',&n', cmd.columns, fld => {