@Input() sortable: boolean;
@Input() datatype: string;
@Input() multiSortable: boolean;
+
+ // Used in conjunction with cellTemplate.
+ @Input() cellContext: any;
@Input() cellTemplate: TemplateRef<any>;
// get a reference to our container grid.
col.hidden = this.hidden === true;
col.isIndex = this.index === true;
col.cellTemplate = this.cellTemplate;
+ col.cellContext = this.cellContext;
col.isSortable = this.sortable;
col.isMultiSortable = this.multiSortable;
this.grid.context.columnSet.add(col);
(dblclick)="onRowDblClick(row)"
(click)="onRowClick($event, row, idx)"
*ngFor="let col of context.columnSet.displayColumns()">
- {{context.getRowColumnValue(row, col)}}
+ <span *ngIf="!col.cellTemplate">
+ {{context.getRowColumnValue(row, col)}}
+ </span>
+ <span *ngIf="col.cellTemplate">
+ <ng-container
+ *ngTemplateOutlet="col.cellTemplate; context: col.getCellContext(row)">
+ </ng-container>
+ </span>
</div>
</div>
</div>
idlFieldDef: any;
datatype: string;
cellTemplate: TemplateRef<any>;
+ cellContext: any;
isIndex: boolean;
isDragTarget: boolean;
isSortable: boolean;
isMultiSortable: boolean;
+
+ getCellContext(row: any) {
+ return {
+ col: this,
+ row: row,
+ userContext: this.cellContext
+ };
+ }
}
export class EgGridColumnSet {
<div>HERE: {{testDate}}</div>
</div>
-<!-- grid stuff -->
-<!--
-<eg-grid #cbtGrid idlClass="cbt" [dataSource]="btSource">
-</eg-grid>
--->
-
<!-- printing -->
<button class="btn btn-secondary" (click)="doPrint()">Test Print</button>
<ng-template #printTemplate let-world="world">Hello, {{world}}!</ng-template>
+<!-- grid stuff -->
+<ng-template #cellTmpl let-row="row" let-col="col" let-userContext="userContext">
+ HELLO {{userContext.hello}}
+ <button>{{row.id()}}</button>
+</ng-template>
+<eg-grid #cbtGrid idlClass="cbt" [dataSource]="btSource">
+ <eg-grid-column name="test" [cellTemplate]="cellTmpl" [cellContext]="btGridTestContext">
+ </eg-grid-column>
+</eg-grid>
+
+
gridDataSource: EgGridDataSource = new EgGridDataSource();
btSource: EgGridDataSource = new EgGridDataSource();
+ btGridTestContext: any = {hello : 'world'};
testDate: any;