import { isNullOrUndefined } from '@syncfusion/ej2-base' ; import { AggregateColumnModel } from '../models/models' ; import { Cell } from '../models/cell' ; import { AggregateColumn } from '../models/aggregate' ; import { ICellRenderer } from '../base/interface' ; import { appendChildren } from '../base/util' ; import { CellRenderer } from './cell-renderer' ; import { Column } from '../models/column' ; import { refreshAggregateCell } from '../base/constant' ; hidden export class SummaryCellRenderer extends CellRenderer implements ICellRenderer < AggregateColumnModel > { public element : HTMLElement = this . parent . createElement ( 'TD' , { className : 'e-summarycell' , attrs : { role : 'gridcell' , tabindex : '-1' } } ) ; public getValue ( field , data , column ) { let key ; key = ! isNullOrUndefined ( column . type ) ? column . field + ' - ' + ( typeof column . type === 'string' ? column . type . toLowerCase ( ) : '' ) : column . columnName ; return data [ column . columnName ] ? data [ column . columnName ] [ key ] : '' ; } public evaluate ( node , cell , data , attributes ? ) { let column = < AggregateColumn > cell . column ; this . parent . on ( refreshAggregateCell , this . refreshWithAggregate ( node , cell ) , this ) ; if ( ! ( column . footerTemplate || column . groupFooterTemplate || column . groupCaptionTemplate ) ) { return true ; } let tempObj = column . getTemplate ( cell . cellType ) ; appendChildren ( node , tempObj . fn ( data [ column . columnName ] , this . parent , tempObj . property ) ) ; return false ; } public refreshWithAggregate ( node , cell ) { let cellNode = cell ; return ( args ) => { let cell = cellNode ; let field = cell . column . columnName ? cell . column . columnName : null ; let curCell = < Cell < Column > > ( ! isNullOrUndefined ( field ) ? args . cells . filter ( ( cell ) => cell . column . columnName === field ) [ 0 ] : null ) ; if ( node . parentElement && node . parentElement . getAttribute ( 'data-uid' ) === args . dataUid && field && field === ( < Cell < Column > & { column : AggregateColumn ; } > curCell ) . column . columnName ) { this . refreshTD ( node , curCell , args . data ) ; } } ; } }