angular - ag-grid external filter using angular2 -
i want implement external filtering on ag-grid angular2.
the ag-grid example on github doesn't seem implement external filters , a similar question has not been answered. there way of implementing external filters in ag-grid angular2?
i have following:
template:
<input (keyup)="updatefilters($event)" name="filteragreementnumber" #filteragreementnumber/> <ag-grid-ng2 #aggrid style="width: 100%;" [style.height.px]="height" class="ag-fresh" [gridoptions]="gridoptions" [rowdata]="promises" (window:resize)="onresize($event)">
component:
export class promiseslistcomponent { private gridoptions: gridoptions; private promises: promise[]; filteragreementnumber = ''; constructor(private promisesservice: promisesservice) { this.gridoptions = { rowdata: this.promises, columndefs: this.createcolumndefs(), enablecolresize: true, enablesorting: true, enablefilter: true, isexternalfilterpresent: this.externalfilterpresent, doesexternalfilterpass: this.externalfilterpass, } updatefilters(event: any) { this.filteragreementnumber = event.target.value; //correctly assigns property this.gridoptions.api.onfilterchanged(); } externalfilterpass(node: any) { console.log(this.getfilteragreementnumber); //undefined if (this.filteragreementnumber && this.filteragreementnumber.length > 0) if (node.data.agreementcode.indexof(this.filteragreementnumber) === -1) return false; return true; } }
the problem having this
in externalfilterpass
refers ag-grid node , have no way of accessing class property.
in constructor, instead of
this.gridoptions = { ... isexternalfilterpresent: this.externalfilterpresent, doesexternalfilterpass: this.externalfilterpass }
try
this.gridoptions = { ... isexternalfilterpresent: this.externalfilterpresent.bind(this), doesexternalfilterpass: this.externalfilterpass.bind(this) }
now component context accessible within ag-grid methods, , this
expected be.
Comments
Post a Comment