Img 1: without filter template(textbox)
Img 2: with filter template(dropdown)
|
<ejs-grid #grid [dataSource]='data' [filterSettings]='filterSettings' allowFiltering='true'>
<e-columns>
. . . . .
<e-column field='Verified' [filter] = 'filter' headerText='Verified' width='150'></e-column>
</e-columns>
</ejs-grid>
<ng-template #filterItemTemplate let-data >{{getFilterItemValue(data)}}</ng-template>
|
export class AppComponent {
. . . . .
@ViewChild('filterItemTemplate')
public fltemp: TemplateRef<{}>;
ngOnInit(): void {
. . . . .
this.filterSettings = { type: 'Excel' };
this.filter = {itemTemplate: this.fltemp }
}
public getFilterItemValue(e: any) {
if (e.Verified == "Select All") {
return e.Verified
}
else if(e.Verified === true){
return "Show selected IDs"
} else{
return "Show Unselected IDs"
}
}
}
|
Hi Neo,
Thanks for sharing the details.
We have analyzed your requirement and we have an option to customize the excel filter check list. For your reference, we have created a sample. In the below sample, we have customize the excel check list using itemTemplate property of columns in Grid.
Please refer the below sample and code example for more information.
<ejs-grid #grid [dataSource]='data' [filterSettings]='filterSettings' allowFiltering='true'><e-columns>. . . . .<e-column field='Verified' [filter] = 'filter' headerText='Verified' width='150'></e-column></e-columns></ejs-grid><ng-template #filterItemTemplate let-data >{{getFilterItemValue(data)}}</ng-template>
export class AppComponent {. . . . .@ViewChild('filterItemTemplate')public fltemp: TemplateRef<{}>;ngOnInit(): void {. . . . .this.filterSettings = { type: 'Excel' };this.filter = {itemTemplate: this.fltemp }}public getFilterItemValue(e: any) {if (e.Verified == "Select All") {return e.Verified}else if(e.Verified === true){return "Show selected IDs"} else{return "Show Unselected IDs"}}}
Please get back to us if you require further assistance on this.
Regards,R.Dhivya
Hi Neo,
Thanks for your update.
We are happy to hear that the provided solution was helpful to achieve your requirement. Please get back to us if you require further assistance on this.
Regards,R.Dhivya
ngOnInit() {
this.filterSettings = {type: 'Excel'};
console.log("INIT:",this.filterTemplate);
}
ngAfterViewInit() {
console.log("THIS:",this.filterTemplate);
this.filter = {itemTemplate: this.filterTemplate }
}
public logData(data){
console.log("DATA",data)
return data;
}In the HTML
<e-column [field]="columns.PROPERTY"
[headerText]="'txt.Property' | translate" [allowEditing]="false"
[filter]="filter"
>
<ng-template #template let-row>
{{row.propertyName | translate}}
ng-template>
e-column>
<ng-template #customFilter let-data >{{logData(data)}}ng-template>
<ejs-grid #grid [dataSource]='data' ... >
<e-columns>
<e-column field='Verified' headerText='Verified' width='150'>
<ng-template #filterItemTemplate let-data>{{getFilterItemValue(data)}}</ng-template>
</e-column>
</e-columns>
</ejs-grid> |
public getFilterItemValue(e: any) {
if (e.Verified == "Select All") {
return e.Verified
}
else if (e.Verified === true) {
return "Show selected IDs"
} else {
return "Show Unselected IDs"
}
} |
Hi Neo,
Thanks for your update.
We are happy to hear that the provided solution was helpful to achieve your requirement. Please get back to us if you require further assistance on this.
Regards,R.Dhivya
Hi R.Dhivya,There is an issue when enabling true/false column as checkbox column. Filter Popup of other columns stays open and cannot be closed by clicking Ok or cancel. Below code for your reference,<ejs-grid #grid [(dataSource)]='points' height='115' allowTextWrap='true' allowResizing='true' gridLines='Both'[allowSorting]="true" [allowFiltering]='true' [enableVirtualization]='false' [filterSettings]='filterSettings'><e-columns><e-column headerText=' ' field='isChecked' width='25' [filter]='filter'><ng-template #template let-data><ejs-checkbox [(checked)]="data.isChecked" (change)='checkBoxChange(data)'>ejs-checkbox>ng-template>e-column><e-column [isPrimaryKey]='true' field='dataCollectionPointCode' headerTextAlign='center' headerText='Point ID'textAlign='Left' width='100'>e-column><e-column field='dataCollectionPointName' headerTextAlign='center' textAllign headerText='Point Name'textAlign='Left' width='100'>e-column>e-columns>ejs-grid><ng-template #filterItemTemplate let-data>{{getFilterItemValue(data)}}ng-template>
<ejs-grid #grid [dataSource]='data' ...>
<e-columns>
<e-column field='isChecked' headerText='Is Checked' width='150'>
<ng-template #template let-data>
<ejs-checkbox [(checked)]="data.isChecked" (change)='checkBoxChange(data)'></ejs-checkbox>
</ng-template>
<ng-template #filterItemTemplate let-data>{{getFilterItemValue(data)}}</ng-template>
</e-column>
</e-columns>
</ejs-grid> |
Hi Shamil,We checked your reported problem but unfortunately were unable to reproduce it from our end as the checkbox defined inside the columns template and checkbox filter item data defined inside the columns filterItemTemplate was working fine.We suspect you are defining the filterItemTemplate separately(not inside the corresponding column using ng-template) and trying to access and set it in the TS file. If so, as we had mentioned in our previous update using this approach is not currently working and we have already logged a bug task for that. The fix for this will be included in our weekly patch release scheduled on 7th October 2020. The status of this request can be tracked through this feedback link.So for now you can define them directly inside the Grid columns to achieve your requirement. This is demonstrated in the below code snippet,
<ejs-grid #grid [dataSource]='data' ...><e-columns><e-column field='isChecked' headerText='Is Checked' width='150'><ng-template #template let-data><ejs-checkbox [(checked)]="data.isChecked" (change)='checkBoxChange(data)'></ejs-checkbox>&nbs