Column 1 | Column 2 | Column 3 |
123 | AAbbbCCC | 1 |
456 | BBCCC | 2 |
789 | BBAADD | 3 |
012 | DDBB | 4 |
345 | DDCC | 5 |
678 | BBDDCC | 6 |
901 | BBAADD | 7 |
Column 1 | Column 2 | Column 3 |
789 | BBAADD | 3 |
012 | DDBB | 4 |
901 | BBAADD | 7 |
@Grid
<input type="button" value="filter" ej-button id="button" (click)="buttonClick($event)" />
<ej-grid #grid [dataSource]="gridData" [allowPaging]="true" (create)="create($event)" [allowFiltering]="true" [filterSettings]="filter" >
</ej-grid>
@Create event
create(e: any) {
//create event in Grid
var isNull = function (val) {
return val === undefined || val === null;
};
var toLowerCase = function (val) {
return val ? val.toLowerCase ? val.toLowerCase() : val.toString().toLowerCase() : (val === 0 || val === false) ? val.toString() : "";
};
var b = {
//set the customized filter operator
notcontains: function (actual, expected, ignoreCase) {
if (ignoreCase)
return !(!isNull(actual) && !isNull(expected) && toLowerCase(actual).indexOf(toLowerCase(expected)) != -1);
return !(!isNull(actual) && !isNull(expected) && actual.toString().indexOf(expected) != -1);
}
}
var a = $.extend(true, ej.data.fnOperators, b);// add the customized filter operator to default filters
} |
@button click event
buttonClick(e: any) {
this.Grid.widget.filterColumn("Column2", "notcontains", "CC"); //filter the column based on customized operator
} |
@Grid
<input type="button" value="filter" ej-button id="button" (click)="buttonClick($event)" />
<ej-grid #grid [dataSource]="gridData" [allowPaging]="true" (create)="create($event)" [allowFiltering]="true" [filterSettings]="filter" >
</ej-grid>
@button click event
buttonClick(e: any) {
this.Grid.widget.model.filterSettings.filteredColumns.push({ field: "Column2", operator: "notcontains", value: "CC", predicate: "and" }) //filter the column based on customized operator
this.Grid.widget.refreshContent(); //refresh the grid
}
|