Reputation: 5911
I have a project that uses an Angular 4 Kendo UI Grid.
<kendo-grid-column
*ngIf="isVisible('fieldName')"
field="fieldName"
title="Some random field name">
</kendo-grid-column>
The isVisible()
method checks if this columns should be visible or not based on the property I pass to kendo-grid-column
. I would like to get the field name I specify in field=fieldName"
dynamically so I don't have to the same text twice for every column.
Something "magical" like this:
<kendo-grid-column
*ngIf="isVisible(kendo.getField())"
field="fieldName"
title="Some random field name">
</kendo-grid-column>
Upvotes: 0
Views: 1577
Reputation: 6325
you can use [hidden]
option in the kendo-grid-column
Example:-
<kendo-grid [data]="gridData">
<ng-template ngFor [ngForOf]="columns" let-column>
<kendo-grid-column
field="{{column}}"
[hidden]="isVisible(column)"
>
</kendo-grid-column>
</ng-template>
</kendo-grid>
Component file
public isVisible(field: string): void {
// based on your condition you can return true to hide
// false to show column
return false;
}
plunker http://plnkr.co/edit/kk8nj4P8k4qY1psexInd?p=preview
Upvotes: 1