Angular-QueryBuilder
Angular-QueryBuilder copied to clipboard
nullable: true is not clearing the old value
If any property in config has nullable: true
, then after entering something in the input box and changing the operator to is null
is not clearing the old value.
school: { name: 'School', type: 'string', nullable: true },
Have you found the solution for your above query?
@Shah-ali I have written a custom logic for this issue. Whenever there is a change in query builder model (ngModelChange), I am calling below method to clear those values.
public removeValueForNullAndEmptyOperator(query: RuleSet) {
query.rules.forEach((rule: Rule | RuleSet) => {
if ((rule as RuleSet).rules) {
return this.removeValueForNullAndEmptyOperator(rule as RuleSet);
}
const ruleWithNull = ['is null', 'is not null', 'is empty', 'is not empty'].includes((rule as Rule).operator ?? '');
if (ruleWithNull) {
delete (rule as Rule).value;
}
});
}