@@ -34,6 +34,7 @@ describe('IgxGrid - Column properties #grid', () => {
34
34
ColumnsFromIterableComponent ,
35
35
TemplatedColumnsComponent ,
36
36
TemplatedInputColumnsComponent ,
37
+ TemplatedContextInputColumnsComponent ,
37
38
ColumnCellFormatterComponent ,
38
39
ColumnHaederClassesComponent ,
39
40
ColumnHiddenFromMarkupComponent ,
@@ -308,6 +309,20 @@ describe('IgxGrid - Column properties #grid', () => {
308
309
309
310
} ) ;
310
311
312
+ it ( 'should support passing properties through the additionalTemplateContext input property' , ( ) => {
313
+ const fixture = TestBed . createComponent ( TemplatedContextInputColumnsComponent ) ;
314
+ fixture . detectChanges ( ) ;
315
+
316
+ const grid = fixture . componentInstance . instance ;
317
+ const contextObject = { property1 : 'cellContent' , property2 : 'cellContent1' } ;
318
+ const firstColumn = grid . columns [ 0 ] ;
319
+ const secondColumn = grid . columns [ 1 ] ;
320
+
321
+ expect ( firstColumn . additionalTemplateContext ) . toEqual ( contextObject ) ;
322
+ expect ( firstColumn . cells [ 0 ] . nativeElement . innerText ) . toEqual ( contextObject . property1 ) ;
323
+ expect ( secondColumn . cells [ 0 ] . nativeElement . innerText ) . toEqual ( contextObject . property2 ) ;
324
+ } ) ;
325
+
311
326
it ( 'should apply column\'s formatter programmatically' , ( ) => {
312
327
const expectedVal = [ 'Johny' , 'Sally' , 'Tim' ] ;
313
328
const expectedValToLower = [ 'johny' , 'sally' , 'tim' ] ;
@@ -1133,6 +1148,31 @@ export class TemplatedInputColumnsComponent {
1133
1148
public columns = Object . keys ( this . data [ 0 ] ) ;
1134
1149
}
1135
1150
1151
+
1152
+ @Component ( {
1153
+ template : `
1154
+ <igx-grid [data]="data">
1155
+ <igx-column [additionalTemplateContext]="contextObject" field="FirstName">
1156
+ <ng-template igxCell let-cell="cell">
1157
+ {{ cell.column.additionalTemplateContext.property1 }}
1158
+ </ng-template>
1159
+ </igx-column>
1160
+ <igx-column [additionalTemplateContext]="contextObject">
1161
+ <ng-template igxCell let-cell="cell" let-props="additionalTemplateContext">
1162
+ {{ props.property2 }}
1163
+ </ng-template>
1164
+ </igx-column>
1165
+ </igx-grid>
1166
+ `
1167
+ } )
1168
+ export class TemplatedContextInputColumnsComponent {
1169
+ @ViewChild ( IgxGridComponent , { read : IgxGridComponent , static : true } )
1170
+ public instance : IgxGridComponent ;
1171
+ public contextObject = { property1 : 'cellContent' , property2 : 'cellContent1' } ;
1172
+
1173
+ public data = SampleTestData . personNameAgeData ( ) ;
1174
+ }
1175
+
1136
1176
@Component ( {
1137
1177
template : `
1138
1178
<igx-grid [data]="data" height="500px" width="400px">
0 commit comments