Skip to content

Commit 5946b32

Browse files
Merge pull request #4383 from syncfusion-content/EJ2-965646-search-hotfix
965646: Updated search using multiple keywords sample in hotfix
2 parents fd52044 + 4a31af8 commit 5946b32

File tree

2 files changed

+20
-6
lines changed
  • ej2-asp-core-mvc/code-snippet/grid/search/search-multiple-keywords

2 files changed

+20
-6
lines changed

ej2-asp-core-mvc/code-snippet/grid/search/search-multiple-keywords/razor

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,27 @@
3939
}
4040
}
4141
function actionComplete(args) {
42+
var grid = document.getElementById("Search").ej2_instances[0];
4243
if (args.requestType === 'refresh') {
43-
var grid = document.getElementById("Search").ej2_instances[0];
4444
var searchBar = document.querySelector('#' + grid.element.id + '_searchbar');
4545
if (searchBar) {
4646
if (this.valueAssign) {
4747
searchBar.value = this.values || '';
4848
this.valueAssign = false;
49-
} else if (removeQuery) {
49+
} else if (this.removeQuery && searchBar.value=='') {
5050
searchBar.value = ''
5151
grid.query = new ej.data.Query();
52-
removeQuery = false;
52+
this.removeQuery = false;
5353
grid.refresh();
5454
}
5555
}
56+
document.getElementById(grid.element.id + '_searchbar').addEventListener('keyup', (args) => {
57+
if (args.target.value === '' && (args.key === 'Enter' || args.key === 'Backspace')) {
58+
grid.query = new ej.data.Query();
59+
removeQuery = false;
60+
grid.refresh();
61+
}
62+
});
5663
}
5764
}
5865
</script>

ej2-asp-core-mvc/code-snippet/grid/search/search-multiple-keywords/tagHelper

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,27 @@
4141
}
4242
}
4343
function actionComplete(args) {
44+
var grid = document.getElementById("Search").ej2_instances[0];
4445
if (args.requestType === 'refresh') {
45-
var grid = document.getElementById("Search").ej2_instances[0];
4646
var searchBar = document.querySelector('#' + grid.element.id + '_searchbar');
4747
if (searchBar) {
4848
if (this.valueAssign) {
4949
searchBar.value = this.values || '';
5050
this.valueAssign = false;
51-
} else if (removeQuery) {
51+
} else if (this.removeQuery && searchBar.value=='') {
5252
searchBar.value = ''
5353
grid.query = new ej.data.Query();
54-
removeQuery = false;
54+
this.removeQuery = false;
5555
grid.refresh();
5656
}
5757
}
58+
document.getElementById(grid.element.id + '_searchbar').addEventListener('keyup', (args) => {
59+
if (args.target.value === '' && (args.key === 'Enter' || args.key === 'Backspace')) {
60+
grid.query = new ej.data.Query();
61+
removeQuery = false;
62+
grid.refresh();
63+
}
64+
});
5865
}
5966
}
6067
</script>

0 commit comments

Comments
 (0)