Skip to content

Commit bf04a22

Browse files
committed
fix(FIlter): Rearranged onInput logic
1 parent 26da553 commit bf04a22

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/app/grid-filter-template/grid-filter-template.sample.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,25 +490,27 @@ export class GridFilterTemplateSampleComponent implements OnInit {
490490
public onInput(input: any, column: IgxColumnComponent) {
491491
let operand = null;
492492
let value = input.value;
493+
494+
if (value === '') {
495+
this.grid1.clearFilter(column.field);
496+
return;
497+
}
498+
493499
switch (column.dataType) {
494500
case DataType.Number:
495501
value = Number.parseInt(value, 10);
496502
operand = IgxNumberFilteringOperand.instance().condition('equals');
497503
break;
498504
case DataType.Date:
499-
value = value !== '' ? new Date(value) : null;
505+
value = new Date(value);
500506
operand = IgxDateFilteringOperand.instance().condition('equals');
501507
break;
502508
default:
503509
operand = IgxStringFilteringOperand.instance().condition('contains');
504510
break;
505511
}
506512

507-
if (value && value !== '') {
508-
this.grid1.filter(column.field, value, operand, column.filteringIgnoreCase);
509-
} else {
510-
this.grid1.clearFilter(column.field);
511-
}
513+
this.grid1.filter(column.field, value, operand, column.filteringIgnoreCase);
512514
}
513515

514516
public clearInput(input: any, column: any) {

0 commit comments

Comments
 (0)