improved multi column filter #855

This commit is contained in:
Jan Prochazka
2024-07-24 13:52:34 +02:00
parent e5fb3414fe
commit 315c0670d0

View File

@@ -214,14 +214,14 @@ export abstract class GridDisplay {
} }
if (this.baseTableOrView && this.config.multiColumnFilter) { if (this.baseTableOrView && this.config.multiColumnFilter) {
try {
const condition = parseFilter(this.config.multiColumnFilter, 'string');
if (condition) {
const orCondition: CompoudCondition = { const orCondition: CompoudCondition = {
conditionType: 'or', conditionType: 'or',
conditions: [], conditions: [],
}; };
for (const column of this.baseTableOrView.columns) { for (const column of this.baseTableOrView.columns) {
try {
const condition = parseFilter(this.config.multiColumnFilter, getFilterType(column.dataType));
if (condition) {
orCondition.conditions.push( orCondition.conditions.push(
_.cloneDeepWith(condition, (expr: Expression) => { _.cloneDeepWith(condition, (expr: Expression) => {
if (expr.exprType == 'placeholder') { if (expr.exprType == 'placeholder') {
@@ -230,14 +230,15 @@ export abstract class GridDisplay {
}) })
); );
} }
} catch (err) {
// skip for this column
continue;
}
}
if (orCondition.conditions.length > 0) { if (orCondition.conditions.length > 0) {
conditions.push(orCondition); conditions.push(orCondition);
} }
} }
} catch (err) {
console.warn(err.message);
}
}
if (conditions.length > 0) { if (conditions.length > 0) {
select.where = { select.where = {
@@ -482,6 +483,7 @@ export abstract class GridDisplay {
this.setConfig(cfg => ({ this.setConfig(cfg => ({
...cfg, ...cfg,
filters: {}, filters: {},
multiColumnFilter: null,
})); }));
this.reload(); this.reload();
} }