actionBegin(args){ //Beverages_Condiments
if(args.requestType === "searching" && args.searchString.length > 0){
args.cancel = true; // prevent the default search action
const text = args.searchString.split('_'); //Split your search text and get the values
console.log(text);
let flag = true;
let predicate: Predicate;
this.val = args.searchString;
// preparing filter query
text.forEach((key) => {
this.grid.getColumns().forEach((col: any) => {
if (flag) {
predicate = new Predicate(col.field, 'contains', key);
flag = false;
} else {
predicate = predicate.or(col.field, 'contains', key);
}
});
});
this.gquery = this.grid.query;
this.grid.query = new Query().where(predicate);
this.grid.searchSettings.key = ''; // resetting the search value
this.grid.refresh();
}
}
Complete(e) {
if (e.requestType === 'refresh') {
this.grid.query = this.gquery;
(document.getElementById(this.grid.element.id + '_searchbar') as HTMLInputElement).value = this.val; // reset the searchstring
}
}
|