all files / grid/renderer/ summary-cell-renderer.js

100% Statements 43/43
100% Branches 35/35
100% Functions 13/13
100% Lines 40/40
9 statements, 5 functions, 9 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57        20× 20× 20×   758× 758×   758×   758× 758× 758× 552×   206× 206× 206×   758× 758× 758× 2696× 2696× 2696× 1960×   2696×   24×            
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/util", "./cell-renderer", "../base/constant"], function (require, exports, ej2_base_1, ej2_base_2, util_1, cell_renderer_1, constant_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var SummaryCellRenderer = (function (_super) {
        __extends(SummaryCellRenderer, _super);
        function SummaryCellRenderer() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.element = ej2_base_2.createElement('TD', { className: 'e-summarycell', attrs: { role: 'gridcell', tabindex: '-1' } });
            return _this;
        }
        SummaryCellRenderer.prototype.getValue = function (field, data, column) {
            var key;
            key = !ej2_base_1.isNullOrUndefined(column.type) ?
                column.field + ' - ' + (typeof column.type === 'string' ? column.type.toLowerCase() : '') : column.columnName;
            return data[column.columnName] ? data[column.columnName][key] : '';
        };
        SummaryCellRenderer.prototype.evaluate = function (node, cell, data, attributes) {
            var column = cell.column;
            this.parent.on(constant_1.refreshAggregateCell, this.refreshWithAggregate(node, cell), this);
            if (!(column.footerTemplate || column.groupFooterTemplate || column.groupCaptionTemplate)) {
                return true;
            }
            var tempObj = column.getTemplate(cell.cellType);
            util_1.appendChildren(node, tempObj.fn(data[column.columnName], this.parent, tempObj.property));
            return false;
        };
        SummaryCellRenderer.prototype.refreshWithAggregate = function (node, cell) {
            var _this = this;
            var cellNode = cell;
            return function (args) {
                var cell = cellNode;
                var field = cell.column.columnName ? cell.column.columnName : null;
                var curCell = (!ej2_base_1.isNullOrUndefined(field) ? args.cells.filter(function (cell) {
                    return cell.column.columnName === field;
                })[0] : null);
                if (node.parentElement && node.parentElement.getAttribute('data-uid') === args.dataUid && field &&
                    field === curCell.column.columnName) {
                    _this.refreshTD(node, curCell, args.data);
                }
            };
        };
        return SummaryCellRenderer;
    }(cell_renderer_1.CellRenderer));
    exports.SummaryCellRenderer = SummaryCellRenderer;
});