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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 8× 8× 8× 8× 8× 1× 95× 95× 95× 95× 95× 420× 420× 95× 95× 4× 4× 91× 91× 95× 1× 420× 420× 420× 420× 420× 420× 420× 186× 186× 182× 182× 420× 1× 1× | /* 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-buttons", "./cell-renderer", "../base/util"], function (require, exports, ej2_base_1, ej2_buttons_1, cell_renderer_1, util_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var CommandColumnRenderer = (function (_super) { __extends(CommandColumnRenderer, _super); function CommandColumnRenderer(parent, locator) { var _this = _super.call(this, parent, locator) || this; _this.buttonElement = ej2_base_1.createElement('button', {}); _this.unbounDiv = ej2_base_1.createElement('div', { className: 'e-unboundcelldiv', styles: 'display: inline-block' }); _this.element = ej2_base_1.createElement('TD', { className: 'e-rowcell e-unboundcell', attrs: { role: 'gridcell', tabindex: '-1' } }); return _this; } CommandColumnRenderer.prototype.render = function (cell, data, attributes) { var node = this.element.cloneNode(); node.appendChild(this.unbounDiv.cloneNode()); node.setAttribute('aria-label', 'is Command column column header ' + cell.column.headerText); Iif (cell.column.commandsTemplate) { util_1.appendChildren(node.firstElementChild, cell.column.getColumnTemplate()(data)); } else { for (var _i = 0, _a = cell.commands; _i < _a.length; _i++) { var command = _a[_i]; node = this.renderButton(node, command, attributes.index); } } this.setAttributes(node, cell, attributes); if (this.parent.isEdit) { ej2_base_1.addClass(node.querySelectorAll('.e-edit-delete'), 'e-hide'); ej2_base_1.removeClass(node.querySelectorAll('.e-save-cancel'), 'e-hide'); } else { ej2_base_1.addClass(node.querySelectorAll('.e-save-cancel'), 'e-hide'); ej2_base_1.removeClass(node.querySelectorAll('.e-edit-delete'), 'e-hide'); } return node; }; CommandColumnRenderer.prototype.renderButton = function (node, buttonOption, index) { var button = this.buttonElement.cloneNode(); ej2_base_1.attributes(button, { 'id': this.parent.element.id + (buttonOption.type || '') + '_' + index, 'type': 'button', title: buttonOption.buttonOption.content || this.localizer.getConstant(buttonOption.type) || buttonOption.type }); button.onclick = buttonOption.buttonOption.click; var buttonObj = new ej2_buttons_1.Button(buttonOption.buttonOption, button); buttonObj.commandType = buttonOption.type; node.firstElementChild.appendChild(buttonObj.element); switch (buttonOption.type) { case 'Edit': case 'Delete': ej2_base_1.addClass([button], ['e-edit-delete', 'e-' + buttonOption.type.toLowerCase() + 'button']); break; case 'Cancel': case 'Save': ej2_base_1.addClass([button], ['e-save-cancel', 'e-' + buttonOption.type.toLowerCase() + 'button']); break; } return node; }; return CommandColumnRenderer; }(cell_renderer_1.CellRenderer)); exports.CommandColumnRenderer = CommandColumnRenderer; }); |