Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grid,filtering): clear filter with empty input #3555

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ export class GridComponent implements OnInit, OnDestroy, AfterViewInit {
}

public filter(target: EventTarget): void {
this.grid1.filter('CountryName', (target as HTMLInputElement).value, IgxStringFilteringOperand.instance().condition('contains'), true);
this.grid1.markForCheck();
const value = (target as HTMLInputElement).value;
if (value) {
this.grid1.filter('CountryName', value, IgxStringFilteringOperand.instance().condition('contains'));
} else {
this.grid1.clearFilter('CountryName');
}
}

public showAlert(element: ElementRef): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export class FilteringSampleComponent implements OnInit {
}

public filter(target: EventTarget) {
this.grid1.filter('ProductName', (target as HTMLInputElement).value, IgxStringFilteringOperand.instance().condition('contains'));
const value = (target as HTMLInputElement).value;
if (value) {
this.grid1.filter('ProductName', value, IgxStringFilteringOperand.instance().condition('contains'));
} else {
this.grid1.clearFilter('ProductName');
}
}

public formatDate(val: Date) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ export class TreeGridFilteringSampleComponent implements OnInit {
}

public filter(element: EventTarget) {
this.treegrid1.filter('Name', (element as HTMLInputElement).value, IgxStringFilteringOperand.instance().condition('contains'));
const value = (element as HTMLInputElement).value;
if (value) {
this.treegrid1.filter('Name', value, IgxStringFilteringOperand.instance().condition('contains'));
} else {
this.treegrid1.clearFilter('Name');
}
}

public formatDate(val: Date) {
Expand Down
Loading