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

92.75% Statements 64/69
90.7% Branches 39/43
100% Functions 11/11
92.42% Lines 61/66
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112        125× 125× 125×   775×   775× 775× 775× 775× 775× 775× 775× 775× 775×                                         773×     773×             773× 773×             775×   775× 58×   775× 775×         775×   775× 775×        
/* 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", "./cell-renderer", "@syncfusion/ej2-inputs"], function (require, exports, ej2_base_1, ej2_base_2, cell_renderer_1, ej2_inputs_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var FilterCellRenderer = (function (_super) {
        __extends(FilterCellRenderer, _super);
        function FilterCellRenderer() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.element = ej2_base_2.createElement('TH', { className: 'e-filterbarcell' });
            return _this;
        }
        FilterCellRenderer.prototype.getGui = function () {
            return ej2_base_2.createElement('div');
        };
        FilterCellRenderer.prototype.render = function (cell, data) {
            var tr = this.parent.element.querySelector('.e-filterbar');
            var node = this.element.cloneNode();
            var innerDIV = this.getGui();
            var input;
            var column = cell.column;
            tr.appendChild(node);
            node.setAttribute('e-mappinguid', column.uid);
            Eif (column.type !== 'checkbox') {
                if ((ej2_base_1.isNullOrUndefined(column.allowFiltering) || column.allowFiltering) && !ej2_base_1.isNullOrUndefined(column.filterBarTemplate)) {
                    node.classList.add('e-fltrtemp');
                    ej2_base_2.attributes(innerDIV, {
                        'class': 'e-fltrtempdiv'
                    });
                    if (ej2_base_1.isNullOrUndefined(column.filterBarTemplate.create)) {
                        input = ej2_base_2.createElement('input', {
                            id: column.field + '_filterBarcell', className: 'e-filterUi_input e-filtertext e-fltrTemp',
                            attrs: { type: 'search', title: column.headerText }
                        });
                        innerDIV.appendChild(input);
                    }
                    else {
                        var args = { column: column, node: Element };
                        var temp = column.filterBarTemplate.create;
                        Iif (typeof temp === 'string') {
                            temp = ej2_base_1.getValue(temp, window);
                        }
                        input = temp(args);
                        Iif (typeof input === 'string') {
                            var div = ej2_base_2.createElement('div');
                            div.innerHTML = input;
                            input = div.firstChild;
                        }
                        ej2_base_2.attributes(innerDIV, {
                            class: 'e-filterUi_input e-filtertext e-fltrTemp',
                            title: column.headerText,
                            id: column.field + '_filterBarcell',
                        });
                        innerDIV.appendChild(input);
                    }
                }
                else {
                    ej2_base_2.attributes(innerDIV, {
                        'class': 'e-filterdiv e-fltrinputdiv'
                    });
                    input = ej2_base_2.createElement('input', {
                        id: column.field + '_filterBarcell', className: 'e-filtertext',
                        attrs: {
                            type: 'search', title: column.headerText + cell.attributes.title,
                            value: data[cell.column.field] ? data[cell.column.field] : '', role: 'search'
                        }
                    });
                    innerDIV.appendChild(input);
                    ej2_inputs_1.Input.createInput({
                        element: input, floatLabelType: 'Never',
                        properties: {
                            enableRtl: this.parent.enableRtl, showClearButton: true
                        }
                    });
                }
                if (column.allowFiltering === false || column.field === '' || ej2_base_1.isNullOrUndefined(column.field)) {
                    input.setAttribute('disabled', 'true');
                    input.classList.add('e-disable');
                }
                if (!column.visible) {
                    node.classList.add('e-hide');
                }
                this.appendHtml(node, innerDIV);
                if ((ej2_base_1.isNullOrUndefined(column.allowFiltering) || column.allowFiltering) && !ej2_base_1.isNullOrUndefined(column.filterBarTemplate)) {
                    var templateWrite = column.filterBarTemplate.write;
                    var args = { element: input, column: column };
                    Iif (typeof templateWrite === 'string') {
                        templateWrite = ej2_base_1.getValue(templateWrite, window);
                    }
                    templateWrite.call(this, args);
                }
            }
            return node;
        };
        FilterCellRenderer.prototype.appendHtml = function (node, innerHtml) {
            node.appendChild(innerHtml);
            return node;
        };
        return FilterCellRenderer;
    }(cell_renderer_1.CellRenderer));
    exports.FilterCellRenderer = FilterCellRenderer;
});