App.component.html
<ejs-grid #grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [filterSettings]='filteringSettings' allowFiltering='true' (actionBegin)="onActionBegin($event)" (actionComplete)="onActionComplete($event)" [query]="query">
. . .
</ejs-grid>
App.component.ts
export class AppComponent {
public data: DataManager;
public pageSettings: Object;
public filteringSettings = { type: 'Excel' };
public query: Query = new Query();
@ViewChild('grid')
public grid: GridComponent;
ngOnInit(): void {
this.data = new DataManager({ url: SERVICE_URI + 'api/Orders', adaptor: new WebApiAdaptor });
this.pageSettings = { pageCount: 3 };
}
public onActionBegin(args) {
}
public onActionComplete(args) {
if (args.requestType == 'filterafteropen') {
document.body.addEventListener('click', (args: any)=> {
if (args.target.id && args.target.id.indexOf('xlfl-frstvalue') > 0 || args.target.id.indexOf('xlfl-secndvalue') > 0 ) {
args.target.onkeyup = this.addfilterParams.bind(this);
}
});
}
}
public addfilterParams (args) {
// here you can send youraddparams for each keystroke
}
} |
App.component.html
<ejs-grid #grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [filterSettings]='filteringSettings' allowFiltering='true' (actionBegin)="onActionBegin($event)" (actionComplete)="onActionComplete($event)" [query]="query">
. . .
</ejs-grid>
App.component.ts
public onActionComplete(args) {
if (args.requestType == 'filterafteropen') {
window.addEventListener('DOMSubtreeModified', (args: any)=> {
if (args.target.id && args.target.id.indexOf('xlfl-frstvalue') > 0 || args.target.id.indexOf('xlfl-secndvalue') > 0 ) {
if(typeof args.target.onkeyup !== 'function') {
args.target.onkeyup = this.addfilterParams.bind(this); //binding onkeyup event for autocomplete element
}
}
})
}
}
public addfilterParams (args) {
// here you can send your addparams for each keystroke
let autoComplete = args.target.ej2_instances[0]; //autoComplete instance.
autoComplete.query.addParams("where" + args.currentTarget.value, args.currentTarget.value);
//adding addParams to autoComplete query
console.log(args, 'Query: ', autoComplete.query.params, args.currentTarget.value);
} |
export class AppComponent {
public columnName: string;
public columnType: string;
@ViewChild('grid', { static: true })
public grid: GridComponent;
. . .
public onActionComplete(args) {
const angularArgs = args;
const angularObj = this;
if (args.requestType == 'filterafteropen') {
this.columnName = args.columnName; //store the current columnName in type
this.columnType = args.columnType;
document.body.addEventListener('DOMSubtreeModified', (args: any) => {
if (args.target.id && args.target.id.indexOf('xlfl-frstvalue') > 0 || args.target.id.indexOf('xlfl-secndvalue') > 0) {
if (typeof args.target.onkeyup !== 'function') {
args.target.onkeyup = this.addfilterParams.bind(angularObj, angularArgs, args);
}
}
})
}
}
public addfilterParams(args, args2, args3) {
console.log(args, args2, args3, this.columnName, this.columnType) //, 'Query: ', autoComplete.query.params, args.currentTarget.value);
// here you can send youraddparams for each keystroke
// let autoComplete = args.target.ej2_instances[0];
// autoComplete.query.addParams("where" + args.currentTarget.value, args.currentTarget.value);
}
} |
App.component.ts
import { debounce } from '@syncfusion/ej2-base';
document.body.addEventListener('DOMSubtreeModified', (args: any) => {
if (args.target.id && args.target.id.indexOf('xlfl-frstvalue') > 0 || args.target.id.indexOf('xlfl-secndvalue') > 0) {
if (typeof args.target.onkeyup !== 'function') {
this.searchHandler = debounce(this.addfilterParams.bind(angularObj, angularArgs, args), 200);
// you can set your time delay here in (milliseconds) args.target.onkeyup = this.searchHandler;
}
}
}) |
App.componment.html
<ejs-grid #grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [filterSettings]='filteringSettings' allowFiltering='true' (actionBegin)="onActionBegin($event)" (actionComplete)="onActionComplete($event)">
</ejs-grid>
App.component.ts
public onActionComplete(args) {
const angularArgs = args;
const angularObj = this;
if (args.requestType == 'filterafteropen') {
this.columnName = args.columnName;9
this.columnType = args.columnType;
document.body.addEventListener('DOMSubtreeModified', (args: any) => {
if (args.target.id && args.target.id.indexOf('xlfl-frstvalue') > 0 || args.target.id.indexOf('xlfl-secndvalue') > 0) {
if(args.target.classList.contains('e-control') && args.target.classList.contains('e-autocomplete')){
this.autoCompleteObj = args.target['ej2_instances'][0];
this.autoCompleteObj.minLength = 5; //By setting minLength as 5 it will not sent request until the 5 letters are entered.
this.autoCompleteObj.filtering = function(args){
//here you can pass your addparams as per your requirement
if (args.text.length >= (this as AutoComplete).minLength)
{
(this as AutoComplete).query.addParams('where'+ args.text, args.text);
}
}
}
}
})
}
} |