@@ -24,7 +24,7 @@ import { formatCurrency, formatDate, PlatformUtil } from '../core/utils';
24
24
import { IgxGridSelectionService } from './selection/selection.service' ;
25
25
import { HammerGesturesManager } from '../core/touch' ;
26
26
import { GridSelectionMode } from './common/enums' ;
27
- import { CellType , ColumnType , GridType , IGX_GRID_BASE , RowType } from './common/grid.interface' ;
27
+ import { CellType , ColumnType , GridType , IgxCellTemplateContext , IGX_GRID_BASE , RowType } from './common/grid.interface' ;
28
28
import { getCurrencySymbol , getLocaleCurrencyCode } from '@angular/common' ;
29
29
import { GridColumnDataType } from '../data-operations/data-util' ;
30
30
import { IgxRowDirective } from './row.directive' ;
@@ -210,24 +210,25 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy, CellT
210
210
*
211
211
* @memberof IgxGridCellComponent
212
212
*/
213
- public get context ( ) : any {
214
- const ctx = {
213
+ public get context ( ) : IgxCellTemplateContext {
214
+ const getCellType = ( ) => this . getCellType ( true ) ;
215
+ const ctx : IgxCellTemplateContext = {
215
216
$implicit : this . value ,
216
- additionalTemplateContext : this . column . additionalTemplateContext
217
+ additionalTemplateContext : this . column . additionalTemplateContext ,
218
+ get cell ( ) {
219
+ /* Turns the `cell` property from the template context object into lazy-evaluated one.
220
+ * Otherwise on each detection cycle the cell template is recreating N cell instances where
221
+ * N = number of visible cells in the grid, leading to massive performance degradation in large grids.
222
+ */
223
+ return getCellType ( ) ;
224
+ }
217
225
} ;
218
226
if ( this . editMode ) {
219
- ctx [ ' formControl' ] = this . formControl ;
227
+ ctx . formControl = this . formControl ;
220
228
}
221
229
if ( this . isInvalid ) {
222
- ctx [ ' defaultErrorTemplate' ] = this . defaultErrorTemplate ;
230
+ ctx . defaultErrorTemplate = this . defaultErrorTemplate ;
223
231
}
224
- /* Turns the `cell` property from the template context object into lazy-evaluated one.
225
- * Otherwise on each detection cycle the cell template is recreating N cell instances where
226
- * N = number of visible cells in the grid, leading to massive performance degradation in large grids.
227
- */
228
- Object . defineProperty ( ctx , 'cell' , {
229
- get : ( ) => this . getCellType ( true )
230
- } ) ;
231
232
return ctx ;
232
233
}
233
234
0 commit comments