Dynamic grid with dynamic headerTemplate
i would like to use an Angular component as header of a grid-column. Is this supported?
I got a component being rendered inside the template but I don't know how to let the component be aware of the actual column it is in. I am creating a grid component dynamically and using stacked headers, if this matters.
Could you provide an example?
Thanks
Thomas
Hi Saravanan,
I have rendered the grid with columns defined by an array of objects using ng-template and ng-for:
<e-columns>
<ng-template ngFor let-column [ngForOf]="columns">
<e-column [field]="column.columnField" [headerText]="column.columnHeaderText"
[allowEditing]="column.allowEditing"
[editSettings]="column.editSettings"
[editType]="column.editType"
[isPrimaryKey]="column.isPrimaryKey"
[headerTemplateID]="column.headerTemplateID">
</e-column>
</ng-template>
</e-columns>
This will be the template then - the deliveryHeaderTemplate is further the selector for an angular-component - and this template will be used for a couple of columns:
<div id="deliveryHeaderTemplate" style="visibility:hidden">
<deliveryHeaderTemplate [someStuff]="this._deliveries"></deliveryHeaderTemplate>
</div>
Then I would like the component being rendered in <deliveryHeaderTemplate /> to know in which column of the grid it is in (i.e. have access to the actual value of column.columnField)
The template will then be manipulated by the logic of the deliveryHeaderTemplate-component.
Thank you for your support and let me know if need any further information.
Regards,
Thomas
|
<ej-grid [allowPaging]="true" [editSettings]="editsettings" [pageSettings.pageSize]="pagesize" [dataSource]="gridData">
<e-columns>
<ng-template ngFor let-column [ngForOf]="columns">
<e-column [field]="column.field"
[headerText]="column.headerText"
[allowEditing]="column.allowEditing"
[isPrimaryKey]="column.isPrimaryKey != null ? column.isPrimaryKey : null"
[width] = "column.width"
[headerTemplateID]="column.headerTemplateID != null ? column.headerTemplateID : null">
</e-column>
</ng-template>
</e-columns>
</ej-grid>
<div id="test">
<my-comp [mytext]="TestTemplate"></my-comp>
</div>
|
Thanks, that worked for me!
- 5 Replies
- 2 Participants
-
TG Thomass Gress
- Aug 3, 2017 11:25 AM UTC
- Aug 23, 2017 08:36 AM UTC