all files / base/ layout-render.js

96.78% Statements 752/777
86.33% Branches 360/417
99.01% Functions 100/101
96.7% Lines 733/758
11 statements, 6 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127          88× 88× 88× 88× 88× 88× 88× 88× 88× 88× 88×   112×   111× 111× 111× 111×     111× 111× 111× 111×   111× 111× 111× 111× 111× 111× 111× 111× 111× 111× 86×     115× 115× 115×       115× 115× 115× 115× 115×   115× 115× 115× 448× 445× 445×       445× 445× 123× 123×     445× 445× 445× 445× 445× 445× 445× 20×       20× 20× 20× 20×     425× 425× 425× 410×       410×     445× 123× 123× 123×       123× 123× 123×   445× 445× 445× 445× 445×         115× 115× 448× 448×     111× 111× 111× 111× 111×       111× 111× 111× 111× 111× 111× 111× 111× 111× 432× 432×       432× 372×   432×     433× 433× 433× 1696× 1696× 1679× 1679× 1679×   1679×         1679×     1679× 96× 96× 96×   1679×     433× 433× 433× 433× 433×     432×         111×     373× 373× 373×     373× 373×     373× 373× 373× 373×           373× 373× 373× 373× 373×     365×           373× 373×         373× 373× 373× 373× 373× 373×     372×         114× 114× 114× 114× 114× 114× 114× 447× 447× 1751× 1734×   1734× 1734× 1734×     1734×     1734× 223× 223×   1734× 1734× 1398× 5165× 5165× 5165× 5165×       5165× 5165× 5165× 5165×       1398× 5165× 5165×       336×       447× 1751× 1751×   447×       114×     5221×             5221× 194× 194× 194× 194×     5027× 5027× 5018× 5018× 5018×       5018× 5018× 5018×   5027×       5027× 5027×         5027×   5027× 15× 15×           5221×   352×       352×   226× 226× 226× 880× 874× 874× 874× 874×           874×     226×   134× 134× 134× 77× 4952× 4945×   835×     4117× 4117× 4117×           4117×   77× 255081×   77× 77× 573× 39425×       77×       57×   134×   77×       1131× 77×     77×   12× 12× 24× 24× 12×     12×                     327× 327× 327× 327× 327×   32× 32× 32× 32×       327× 10×   327× 327× 327×     327×     326×     327×                                                                     4779× 4779× 4779× 4779× 132×     4750×   4779×   126× 126× 126×         126× 126×         126× 126× 123×           153× 153× 603× 582×   21× 21× 21× 21× 21× 18× 123× 123× 490×   123× 123× 88×                 126× 126×   125× 89×   126×   42× 48× 42× 42× 42× 42× 42×   2423× 2423× 2423× 2423× 2423× 65× 450×   65×     2358× 2358× 2408× 67104×   2408×   2358× 2408× 2408×     2423× 2423×   2423× 2423× 2423×   82× 82×     2341× 479×   2341× 2341×   2423×   2423× 2423× 2411×   2423× 16×   2407× 2407× 2407× 13046× 477× 477×     12569× 12569×   13046×   2407× 430×   2407×   26×         26× 26×           28×     27×     225× 225× 225× 225× 891× 891× 40×     868×   891× 891×   225×   143× 143× 143× 86× 639× 43382×           143×     60×   42× 42× 42× 171× 171×   171× 171× 171× 163× 163× 163×     159× 159× 166× 166× 166×     163×       42× 23× 23× 179× 179× 179× 179× 179×       42×   327× 327× 327× 327× 327×             327× 327× 6112× 5800× 5800× 4482× 4482×                   56× 56× 56× 56× 29× 29× 28×               56×   16×           52×   10×   56× 56× 226×   56× 56× 56×   56× 56× 56× 56×   56× 56× 56× 56×     52×           52× 52× 52× 52× 52× 52×   52× 11×     111× 111× 111× 111× 111× 111× 111× 111× 1666× 1205×   1666×   111×   111×   199× 199× 199× 199× 199× 199× 109× 109× 108×     198× 1659× 198× 15×     115× 115× 114×   114× 5110×     109× 109×   109× 4982×   199× 199× 199× 199× 198× 198× 108×   198× 198× 108×   198×   198×   198× 198×   198× 198×          
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        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 extendStatics(d, b);
    };
    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", "./mobile-layout", "../base/constant", "../base/css-constant"], function (require, exports, ej2_base_1, mobile_layout_1, events, cls) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var LayoutRender = (function (_super) {
        __extends(LayoutRender, _super);
        function LayoutRender(parent) {
            var _this = _super.call(this, parent) || this;
            _this.kanbanRows = [];
            _this.parent = parent;
            _this.columnKeys = [];
            _this.swimlaneIndex = 0;
            _this.swimlaneData = {};
            _this.scrollLeft = 0;
            _this.frozenOrder = 0;
            _this.parent.on(events.dataReady, _this.initRender, _this);
            _this.parent.on(events.contentReady, _this.scrollUiUpdate, _this);
            return _this;
        }
        LayoutRender.prototype.initRender = function () {
            if (this.parent.columns.length === 0) {
                return;
            }
            this.columnData = this.getColumnCards();
            this.kanbanRows = this.getRows();
            this.swimlaneData = this.getSwimlaneCards();
            if (this.parent.isAdaptive) {
                var parent_1 = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
                if (parent_1) {
                    this.scrollLeft = parent_1.scrollLeft;
                }
            }
            this.destroy();
            this.parent.on(events.dataReady, this.initRender, this);
            this.parent.on(events.contentReady, this.scrollUiUpdate, this);
            if (this.parent.isAdaptive && this.parent.swimlaneSettings.keyField && this.parent.kanbanData.length !== 0) {
                this.renderSwimlaneHeader();
            }
            var header = ej2_base_1.createElement('div', { className: cls.HEADER_CLASS });
            this.parent.element.appendChild(header);
            this.renderHeader(header);
            this.renderContent();
            this.renderCards();
            this.renderValidation();
            this.parent.renderTemplates();
            this.parent.notify(events.contentReady, {});
            this.wireEvents();
            if (this.parent.isInitialRender) {
                this.parent.isInitialRender = false;
            }
        };
        LayoutRender.prototype.renderHeader = function (header) {
            var headerWrap = ej2_base_1.createElement('div', { className: this.parent.swimlaneSettings.keyField ? cls.SWIMLANE_CLASS : '' });
            header.appendChild(headerWrap);
            var headerTable = ej2_base_1.createElement('table', {
                className: cls.TABLE_CLASS + ' ' + cls.HEADER_TABLE_CLASS,
                attrs: { 'role': 'presentation' }
            });
            headerWrap.appendChild(headerTable);
            this.renderColGroup(headerTable);
            var tableHead = ej2_base_1.createElement('thead');
            headerTable.appendChild(tableHead);
            if (this.parent.stackedHeaders.length > 0) {
                tableHead.appendChild(this.createStackedRow(this.parent.stackedHeaders));
            }
            var tr = ej2_base_1.createElement('tr', { className: cls.HEADER_ROW_CLASS });
            tableHead.appendChild(tr);
            var _loop_1 = function (column) {
                if (this_1.isColumnVisible(column)) {
                    var index = this_1.parent.actionModule.columnToggleArray.indexOf(column.keyField.toString());
                    var th_1 = ej2_base_1.createElement('th', {
                        className: index === -1 ? cls.HEADER_CELLS_CLASS : cls.HEADER_CELLS_CLASS + ' ' + cls.COLLAPSED_CLASS,
                        attrs: { 'data-role': 'kanban-column', 'data-key': column.keyField.toString() }
                    });
                    var classList = [];
                    if (column.allowToggle) {
                        classList.push(cls.HEADER_ROW_TOGGLE_CLASS);
                        if (!column.isExpanded) {
                            classList.push(cls.COLLAPSED_CLASS);
                        }
                    }
                    ej2_base_1.addClass([th_1], classList);
                    var headerWrapper = ej2_base_1.createElement('div', { className: cls.HEADER_WRAP_CLASS });
                    th_1.appendChild(headerWrapper);
                    var noOfCard = this_1.columnData[column.keyField].length;
                    var headerTitle = ej2_base_1.createElement('div', { className: cls.HEADER_TITLE_CLASS });
                    headerWrapper.appendChild(headerTitle);
                    if (column.template) {
                        var templateArgs = {
                            keyField: column.keyField, headerText: column.headerText, minCount: column.minCount, maxCount: column.maxCount,
                            allowToggle: column.allowToggle, isExpanded: column.isExpanded, showItemCount: column.showItemCount, count: noOfCard
                        };
                        ej2_base_1.addClass([th_1], cls.TEMPLATE_CLASS);
                        var templateId = this_1.parent.element.id + '_columnTemplate';
                        var templateHeader = this_1.parent.templateParser(column.template)(templateArgs, this_1.parent, 'columnTemplate', templateId, false);
                        ej2_base_1.append(templateHeader, headerTitle);
                    }
                    else {
                        var header_1 = ej2_base_1.createElement('div', { className: cls.HEADER_TEXT_CLASS, innerHTML: column.headerText });
                        headerTitle.appendChild(header_1);
                        if (column.showItemCount) {
                            var itemCount = ej2_base_1.createElement('div', {
                                className: cls.CARD_ITEM_COUNT_CLASS,
                                innerHTML: '- ' + noOfCard.toString() + ' ' + this_1.parent.localeObj.getConstant('items')
                            });
                            headerTitle.appendChild(itemCount);
                        }
                    }
                    if (column.allowToggle) {
                        var isExpand = (column.isExpanded && index === -1) ? true : false;
                        var name_1 = (isExpand) ? cls.COLUMN_EXPAND_CLASS : cls.COLUMN_COLLAPSE_CLASS;
                        var icon = ej2_base_1.createElement('div', {
                            className: cls.HEADER_ICON_CLASS + ' ' + cls.ICON_CLASS + ' ' + name_1,
                            attrs: { 'tabindex': '0' }
                        });
                        icon.setAttribute('aria-label', isExpand ? column.keyField + ' Expand' : column.keyField + ' Collapse');
                        th_1.setAttribute('aria-expanded', isExpand.toString());
                        headerWrapper.appendChild(icon);
                    }
                    var dataObj = [{ keyField: column.keyField, textField: column.headerText, count: noOfCard }];
                    var args = { data: dataObj, element: tr, cancel: false, requestType: 'headerRow' };
                    this_1.parent.trigger(events.queryCellInfo, args, function (columnArgs) {
                        Eif (!columnArgs.cancel) {
                            tr.appendChild(th_1);
                        }
                    });
                }
            };
            var this_1 = this;
            for (var _i = 0, _a = this.parent.columns; _i < _a.length; _i++) {
                var column = _a[_i];
                _loop_1(column);
            }
        };
        LayoutRender.prototype.renderContent = function () {
            var content = ej2_base_1.createElement('div', { className: cls.CONTENT_CLASS });
            this.parent.element.appendChild(content);
            var contentWrap = ej2_base_1.createElement('div', { className: this.parent.swimlaneSettings.keyField ? cls.SWIMLANE_CLASS : '' });
            content.appendChild(contentWrap);
            var contentTable = ej2_base_1.createElement('table', {
                className: cls.TABLE_CLASS + ' ' + cls.CONTENT_TABLE_CLASS,
                attrs: { 'role': 'presentation' }
            });
            contentWrap.appendChild(contentTable);
            this.renderColGroup(contentTable);
            var tBody = ej2_base_1.createElement('tbody');
            contentTable.appendChild(tBody);
            var className;
            var isCollaspsed = false;
            this.swimlaneRow = this.kanbanRows;
            this.initializeSwimlaneTree();
            for (var _i = 0, _a = this.swimlaneRow; _i < _a.length; _i++) {
                var row = _a[_i];
                Iif (this.parent.swimlaneSettings.keyField && this.parent.swimlaneToggleArray.length !== 0) {
                    var index = this.parent.swimlaneToggleArray.indexOf(row.keyField);
                    isCollaspsed = index !== -1;
                }
                if (this.parent.swimlaneSettings.keyField && !this.parent.isAdaptive) {
                    this.renderSwimlaneRow(tBody, row, isCollaspsed);
                }
                this.renderSingleContent(tBody, row, isCollaspsed);
            }
        };
        LayoutRender.prototype.renderSingleContent = function (tBody, row, isCollaspsed) {
            var className = isCollaspsed ? cls.CONTENT_ROW_CLASS + ' ' + cls.COLLAPSED_CLASS : cls.CONTENT_ROW_CLASS;
            var tr = ej2_base_1.createElement('tr', { className: className, attrs: { 'aria-expanded': 'true' } });
            for (var _i = 0, _a = this.parent.columns; _i < _a.length; _i++) {
                var column = _a[_i];
                if (this.isColumnVisible(column)) {
                    var index = this.parent.actionModule.columnToggleArray.indexOf(column.keyField.toString());
                    var className_1 = index === -1 ? cls.CONTENT_CELLS_CLASS : cls.CONTENT_CELLS_CLASS + ' ' + cls.COLLAPSED_CLASS;
                    var dragClass = (column.allowDrag ? ' ' + cls.DRAG_CLASS : '') + (column.allowDrop ? ' ' + cls.DROP_CLASS
                        + ' ' + cls.DROPPABLE_CLASS : '');
                    var td = ej2_base_1.createElement('td', {
                        className: className_1 + dragClass,
                        attrs: { 'data-role': 'kanban-column', 'data-key': column.keyField.toString(), 'aria-expanded': 'true',
                            'tabindex': '0', 'role': 'navigation' }
                    });
                    if (column.allowToggle && !column.isExpanded || index !== -1) {
                        ej2_base_1.addClass([td], cls.COLLAPSED_CLASS);
                        var text = (column.showItemCount ? '[' +
                            this.getColumnData(column.keyField, this.swimlaneData[row.keyField]).length + '] ' : '') + column.headerText;
                        td.appendChild(ej2_base_1.createElement('div', { className: cls.COLLAPSE_HEADER_TEXT_CLASS, innerHTML: text }));
                        td.setAttribute('aria-expanded', 'false');
                    }
                    if (column.showAddButton) {
                        var button = ej2_base_1.createElement('div', { className: cls.SHOW_ADD_BUTTON, attrs: { 'tabindex': '-1' } });
                        button.appendChild(ej2_base_1.createElement('div', { className: cls.SHOW_ADD_ICON + ' ' + cls.ICON_CLASS }));
                        td.appendChild(button);
                    }
                    tr.appendChild(td);
                }
            }
            var dataObj = [{ keyField: row.keyField, textField: row.textField, count: row.count }];
            var args = { data: dataObj, element: tr, cancel: false, requestType: 'contentRow' };
            this.parent.trigger(events.queryCellInfo, args, function (columnArgs) {
                Eif (!columnArgs.cancel) {
                    if (tBody.classList.contains('e-swimlane-row')) {
                        tBody.insertAdjacentElement('beforebegin', tr);
                    }
                    else {
                        tBody.appendChild(tr);
                    }
                }
            });
        };
        LayoutRender.prototype.initializeSwimlaneTree = function () {
            if (this.parent.swimlaneSettings.keyField && this.parent.isAdaptive && this.parent.kanbanData.length !== 0) {
                this.swimlaneRow = [this.kanbanRows[this.swimlaneIndex]];
                this.renderSwimlaneTree();
                this.parent.element.querySelector('.' + cls.TOOLBAR_SWIMLANE_NAME_CLASS).innerHTML = this.swimlaneRow[0].textField;
            }
        };
        LayoutRender.prototype.renderSwimlaneRow = function (tBody, row, isCollapsed) {
            var name = cls.CONTENT_ROW_CLASS + ' ' + cls.SWIMLANE_ROW_CLASS;
            var className = isCollapsed ? ' ' + cls.COLLAPSED_CLASS : '';
            var tr = ej2_base_1.createElement('tr', {
                className: name + className, attrs: { 'data-key': row.keyField, 'aria-expanded': (!isCollapsed).toString() }
            });
            var col = this.parent.columns.length - this.parent.actionModule.hideColumnKeys.length;
            var td = ej2_base_1.createElement('td', {
                className: cls.CONTENT_CELLS_CLASS, attrs: { 'data-role': 'kanban-column', 'colspan': col.toString() }
            });
            var swimlaneHeader = ej2_base_1.createElement('div', { className: cls.SWIMLANE_HEADER_CLASS });
            td.appendChild(swimlaneHeader);
            var iconClass = isCollapsed ? cls.SWIMLANE_ROW_COLLAPSE_CLASS : cls.SWIMLANE_ROW_EXPAND_CLASS;
            var iconDiv = ej2_base_1.createElement('div', {
                className: cls.ICON_CLASS + ' ' + iconClass, attrs: {
                    'tabindex': '0',
                    'aria-label': isCollapsed ? row.keyField + ' Collapse' : row.keyField + ' Expand'
                }
            });
            swimlaneHeader.appendChild(iconDiv);
            var headerWrap = ej2_base_1.createElement('div', { className: cls.HEADER_WRAP_CLASS });
            swimlaneHeader.appendChild(headerWrap);
            var cardCount = this.swimlaneData[row.keyField].length;
            if (this.parent.swimlaneSettings.template) {
                var templateArgs = ej2_base_1.extend({}, row, { count: cardCount }, true);
                ej2_base_1.addClass([td], cls.TEMPLATE_CLASS);
                var templateId = this.parent.element.id + '_swimlaneTemplate';
                var swimlaneTemplate = this.parent.templateParser(this.parent.swimlaneSettings.template)(templateArgs, this.parent, 'swimlaneTemplate', templateId, false);
                ej2_base_1.append(swimlaneTemplate, headerWrap);
            }
            else {
                headerWrap.appendChild(ej2_base_1.createElement('div', {
                    className: cls.SWIMLANE_ROW_TEXT_CLASS,
                    innerHTML: row.textField,
                    attrs: { 'data-role': row.textField }
                }));
            }
            Eif (this.parent.swimlaneSettings.showItemCount) {
                swimlaneHeader.appendChild(ej2_base_1.createElement('div', {
                    className: cls.CARD_ITEM_COUNT_CLASS,
                    innerHTML: "- " + cardCount.toString() + " " + this.parent.localeObj.getConstant('items')
                }));
            }
            tr.appendChild(td);
            var dataObj = [{ keyField: row.keyField, textField: row.textField, count: row.count }];
            var args = { data: dataObj, element: tr, cancel: false, requestType: 'swimlaneRow' };
            this.parent.trigger(events.queryCellInfo, args, function (columnArgs) {
                Eif (!columnArgs.cancel) {
                    if (tBody.classList.contains('e-swimlane-row')) {
                        tBody.insertAdjacentElement('beforebegin', tr);
                    }
                    else {
                        tBody.appendChild(tr);
                    }
                }
            });
        };
        LayoutRender.prototype.renderCards = function () {
            var _this = this;
            var rows = this.swimlaneRow;
            var cardRows = [].slice.call(this.parent.element.querySelectorAll('.e-content-row:not(.e-swimlane-row)'));
            var swimlaneRows = [].slice.call(this.parent.element.querySelectorAll('.e-content-row.e-swimlane-row'));
            var removeTrs = [];
            var columnTransition = false;
            cardRows.forEach(function (tr, index) {
                var dataCount = 0;
                var _loop_2 = function (column) {
                    if (_this.isColumnVisible(column)) {
                        var columnData = _this.parent.swimlaneSettings.keyField ?
                            _this.getColumnData(column.keyField, _this.swimlaneData[rows[index].keyField]) : _this.columnData[column.keyField];
                        dataCount += columnData.length;
                        var columnWrapper = tr.querySelector('[data-key="' + column.keyField + '"]');
                        var cardWrapper_1 = ej2_base_1.createElement('div', {
                            className: cls.CARD_WRAPPER_CLASS, attrs: { 'role': 'listbox' }
                        });
                        Iif (column.transitionColumns.length > 0) {
                            columnTransition = true;
                        }
                        if (!columnTransition && ej2_base_1.isNullOrUndefined(_this.parent.swimlaneSettings.keyField)) {
                            var borderElem = ej2_base_1.createElement('div', { className: cls.BORDER_CLASS });
                            columnWrapper.appendChild(borderElem);
                        }
                        columnWrapper.appendChild(cardWrapper_1);
                        if (columnData.length > 0) {
                            var _loop_3 = function (data) {
                                var cardText = data[_this.parent.cardSettings.headerField];
                                var cardIndex = _this.parent.actionModule.selectionArray.indexOf(cardText);
                                var cardElement = _this.renderCard(data);
                                Iif (cardIndex !== -1) {
                                    cardElement.setAttribute('aria-selected', 'true');
                                    ej2_base_1.addClass([cardElement], cls.CARD_SELECTION_CLASS);
                                }
                                var args = { data: data, element: cardElement, cancel: false };
                                _this.parent.trigger(events.cardRendered, args, function (cardArgs) {
                                    Eif (!cardArgs.cancel) {
                                        cardWrapper_1.appendChild(cardElement);
                                    }
                                });
                            };
                            for (var _i = 0, _a = columnData; _i < _a.length; _i++) {
                                var data = _a[_i];
                                _loop_3(data);
                            }
                        }
                        else {
                            cardWrapper_1.appendChild(_this.renderEmptyCard());
                        }
                    }
                };
                for (var _i = 0, _a = _this.parent.columns; _i < _a.length; _i++) {
                    var column = _a[_i];
                    _loop_2(column);
                }
                if (dataCount === 0) {
                    removeTrs.push(tr);
                    if (swimlaneRows.length > 0) {
                        removeTrs.push(swimlaneRows[index]);
                    }
                }
            });
            if (!this.parent.swimlaneSettings.showEmptyRow && (this.parent.kanbanData.length === 0 && !this.parent.showEmptyColumn)) {
                removeTrs.forEach(function (tr) { return ej2_base_1.remove(tr); });
            }
        };
        LayoutRender.prototype.renderCard = function (data) {
            var cardElement = ej2_base_1.createElement('div', {
                className: cls.CARD_CLASS,
                attrs: {
                    'data-id': data[this.parent.cardSettings.headerField], 'data-key': data[this.parent.keyField],
                    'aria-selected': 'false', 'tabindex': '-1', 'role': 'option'
                }
            });
            if (this.parent.cardSettings.template) {
                ej2_base_1.addClass([cardElement], cls.TEMPLATE_CLASS);
                var templateId = this.parent.element.id + '_cardTemplate';
                var cardTemplate = this.parent.templateParser(this.parent.cardSettings.template)(data, this.parent, 'cardTemplate', templateId, false);
                ej2_base_1.append(cardTemplate, cardElement);
            }
            else {
                var tooltipClass = this.parent.enableTooltip ? ' ' + cls.TOOLTIP_TEXT_CLASS : '';
                if (this.parent.cardSettings.showHeader) {
                    var cardHeader = ej2_base_1.createElement('div', { className: cls.CARD_HEADER_CLASS });
                    var cardCaption = ej2_base_1.createElement('div', { className: cls.CARD_HEADER_TEXT_CLASS });
                    var cardText = ej2_base_1.createElement('div', {
                        className: cls.CARD_HEADER_TITLE_CLASS + tooltipClass,
                        innerHTML: data[this.parent.cardSettings.headerField] || ''
                    });
                    cardHeader.appendChild(cardCaption);
                    cardCaption.appendChild(cardText);
                    cardElement.appendChild(cardHeader);
                }
                var cardContent = ej2_base_1.createElement('div', {
                    className: cls.CARD_CONTENT_CLASS + tooltipClass,
                    innerHTML: data[this.parent.cardSettings.contentField] || ''
                });
                cardElement.appendChild(cardContent);
                if (this.parent.cardSettings.tagsField && data[this.parent.cardSettings.tagsField]) {
                    var cardTags = ej2_base_1.createElement('div', { className: cls.CARD_TAGS_CLASS });
                    var tags = data[this.parent.cardSettings.tagsField].toString().split(',');
                    for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
                        var tag = tags_1[_i];
                        cardTags.appendChild(ej2_base_1.createElement('div', {
                            className: cls.CARD_TAG_CLASS + ' ' + cls.CARD_LABEL_CLASS, innerHTML: tag
                        }));
                    }
                    cardElement.appendChild(cardTags);
                }
                if (this.parent.cardSettings.grabberField && data[this.parent.cardSettings.grabberField]) {
                    ej2_base_1.addClass([cardElement], cls.CARD_COLOR_CLASS);
                    cardElement.style.borderLeftColor = data[this.parent.cardSettings.grabberField];
                }
                if (this.parent.cardSettings.footerCssField) {
                    var cardFields = ej2_base_1.createElement('div', { className: cls.CARD_FOOTER_CLASS });
                    var keys = data[this.parent.cardSettings.footerCssField].split(',');
                    for (var _a = 0, keys_1 = keys; _a < keys_1.length; _a++) {
                        var key = keys_1[_a];
                        cardFields.appendChild(ej2_base_1.createElement('div', {
                            className: key.trim() + ' ' + cls.CARD_FOOTER_CSS_CLASS
                        }));
                    }
                    cardElement.appendChild(cardFields);
                }
            }
            return cardElement;
        };
        LayoutRender.prototype.renderEmptyCard = function () {
            var emptyCard = ej2_base_1.createElement('span', {
                className: cls.EMPTY_CARD_CLASS,
                innerHTML: this.parent.localeObj.getConstant('noCard')
            });
            return emptyCard;
        };
        LayoutRender.prototype.renderColGroup = function (table) {
            var _this = this;
            var colGroup = ej2_base_1.createElement('colgroup');
            this.parent.columns.forEach(function (column) {
                if (_this.isColumnVisible(column)) {
                    var index = _this.parent.actionModule.columnToggleArray.indexOf(column.keyField.toString());
                    var isToggle = column.allowToggle && !column.isExpanded;
                    var className = index === -1 ? (isToggle ? cls.COLLAPSED_CLASS : '') : cls.COLLAPSED_CLASS;
                    var col = ej2_base_1.createElement('col', {
                        className: className,
                        attrs: { 'data-key': column.keyField.toString() },
                        styles: _this.parent.isAdaptive ? 'width: ' +
                            (isToggle ? ej2_base_1.formatUnit(events.toggleWidth) : ej2_base_1.formatUnit(_this.getWidth())) : ''
                    });
                    colGroup.appendChild(col);
                }
            });
            table.appendChild(colGroup);
        };
        LayoutRender.prototype.getRows = function () {
            var _this = this;
            var kanbanRows = [];
            if (this.parent.swimlaneSettings.keyField) {
                this.parent.kanbanData.map(function (obj) {
                    if (!_this.parent.swimlaneSettings.showEmptyRow) {
                        if ((ej2_base_1.isNullOrUndefined(obj[_this.parent.keyField])) || (obj[_this.parent.keyField] === '') ||
                            (obj[_this.parent.keyField] && _this.columnKeys.indexOf(obj[_this.parent.keyField].toString()) === -1)) {
                            return;
                        }
                    }
                    var textField = obj[_this.parent.swimlaneSettings.textField] || obj[_this.parent.swimlaneSettings.keyField];
                    var keyField = obj[_this.parent.swimlaneSettings.keyField];
                    if (!obj[_this.parent.swimlaneSettings.keyField]) {
                        Eif (_this.parent.swimlaneSettings.showUnassignedRow) {
                            textField = _this.parent.localeObj.getConstant('unassigned');
                            keyField = '';
                        }
                        else {
                            return;
                        }
                    }
                    kanbanRows.push({ keyField: keyField, textField: textField });
                });
                kanbanRows = kanbanRows.filter(function (item, index, arr) {
                    return index === arr.map(function (item) { return item.keyField; }).indexOf(item.keyField);
                });
                kanbanRows = this.swimlaneSorting(kanbanRows);
                kanbanRows.forEach(function (row) {
                    row.count = _this.parent.kanbanData.filter(function (obj) {
                        return _this.columnKeys.indexOf(obj[_this.parent.keyField]) > -1 &&
                            obj[_this.parent.swimlaneSettings.keyField] === row.keyField;
                    }).length;
                });
                if (kanbanRows.length === 0) {
                    kanbanRows.push({ keyField: '', textField: '' });
                }
            }
            else {
                kanbanRows.push({ keyField: '', textField: '' });
            }
            return kanbanRows;
        };
        LayoutRender.prototype.swimlaneSorting = function (rows) {
            Iif (this.parent.swimlaneSettings.sortComparer) {
                rows = this.parent.swimlaneSettings.sortComparer.call(this.parent, rows);
            }
            else {
                rows.sort(function (a, b) { return a.textField.localeCompare(b.textField, undefined, { numeric: true }); });
                if (this.parent.swimlaneSettings.sortDirection === 'Descending') {
                    rows.reverse();
                }
            }
            return rows;
        };
        LayoutRender.prototype.createStackedRow = function (rows) {
            var tr = ej2_base_1.createElement('tr', { className: cls.HEADER_ROW_CLASS + ' ' + cls.STACKED_HEADER_ROW_CLASS });
            var stackedHeaders = [];
            this.parent.columns.forEach(function (column) {
                var headerText = '';
                for (var _i = 0, rows_1 = rows; _i < rows_1.length; _i++) {
                    var row = rows_1[_i];
                    if (row.keyFields.indexOf(column.keyField.toString()) !== -1) {
                        headerText = row.text;
                    }
                }
                stackedHeaders.push(headerText);
            });
            for (var h = 0; h < stackedHeaders.length; h++) {
                var colSpan = 1;
                for (var j = h + 1; j < stackedHeaders.length; j++) {
                    if ((stackedHeaders[h] !== '') && (stackedHeaders[j] !== '') && stackedHeaders[h] === stackedHeaders[j]) {
                        colSpan++;
                    }
                    else {
                        break;
                    }
                }
                var div = ej2_base_1.createElement('div', { className: cls.HEADER_TEXT_CLASS, innerHTML: stackedHeaders[h] });
                var th = ej2_base_1.createElement('th', {
                    className: cls.HEADER_CELLS_CLASS + ' ' + cls.STACKED_HEADER_CELL_CLASS,
                    attrs: { 'colspan': colSpan.toString() }
                });
                tr.appendChild(th).appendChild(div);
                h += colSpan - 1;
            }
            return tr;
        };
        LayoutRender.prototype.scrollUiUpdate = function () {
            var _this = this;
            var header = this.parent.element.querySelector('.' + cls.HEADER_CLASS);
            var content = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            var height = this.parent.element.offsetHeight - header.offsetHeight;
            if (this.parent.isAdaptive) {
                height = window.innerHeight - (header.offsetHeight + events.bottomSpace);
                var swimlaneToolbar = this.parent.element.querySelector('.' + cls.SWIMLANE_HEADER_CLASS);
                if (swimlaneToolbar) {
                    height -= swimlaneToolbar.offsetHeight;
                }
                var cardWrappers = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CONTENT_CELLS_CLASS));
                cardWrappers.forEach(function (cell) {
                    var cardWrapper = cell.querySelector('.' + cls.CARD_WRAPPER_CLASS);
                    Eif (!cardWrapper.classList.contains(cls.MULTI_CARD_WRAPPER_CLASS)) {
                        cardWrapper.style.height = ej2_base_1.formatUnit(height);
                        ej2_base_1.EventHandler.add(cell, 'touchmove', _this.onAdaptiveScroll, _this);
                    }
                });
            }
            if (this.parent.height !== 'auto' && this.parent.height !== '100%') {
                content.style.height = ej2_base_1.formatUnit(height);
            }
            [].slice.call(header.children).forEach(function (node) {
                var paddingValue = 0;
                if ((content.offsetWidth - content.clientWidth) > 0) {
                    paddingValue = 17;
                    if ((content.offsetHeight - content.clientHeight) > 0) {
                        node.style.width = ej2_base_1.formatUnit(content.clientWidth);
                    }
                }
                if (_this.parent.enableRtl) {
                    node.style.paddingLeft = ej2_base_1.formatUnit(paddingValue);
                }
                else {
                    node.style.paddingRight = ej2_base_1.formatUnit(paddingValue);
                }
            });
            this.updateScrollPosition();
        };
        LayoutRender.prototype.onContentScroll = function (e) {
            var target = e.target;
            var header = this.parent.element.querySelector('.' + cls.HEADER_CLASS);
            [].slice.call(header.children).forEach(function (node) { node.scrollLeft = target.scrollLeft; });
            this.parent.scrollPosition.content = { left: target.scrollLeft, top: target.scrollTop };
            if (!ej2_base_1.isNullOrUndefined(this.parent.swimlaneSettings.keyField) && this.parent.swimlaneSettings.enableFrozenRows) {
                this.frozenRows(e);
            }
        };
        LayoutRender.prototype.addFrozenSwimlaneDataKey = function (currentElem) {
            var frozenKey = currentElem.getAttribute('data-key');
            Eif (!ej2_base_1.isNullOrUndefined(frozenKey)) {
                this.frozenSwimlaneRow.setAttribute('data-key', frozenKey);
            }
        };
        LayoutRender.prototype.frozenRows = function (e) {
            var firstSwimlane = this.parent.element.querySelector('.' + cls.SWIMLANE_ROW_CLASS);
            var header = this.parent.element.querySelector('.' + cls.HEADER_CLASS);
            var content = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            if (ej2_base_1.isNullOrUndefined(this.frozenSwimlaneRow)) {
                this.frozenSwimlaneRow = ej2_base_1.createElement('div', { className: cls.FROZEN_SWIMLANE_ROW_CLASS });
                var frozenRow = ej2_base_1.createElement('div', { className: cls.FROZEN_ROW_CLASS });
                this.frozenSwimlaneRow.appendChild(frozenRow);
                this.parent.element.insertBefore(this.frozenSwimlaneRow, this.parent.element.firstElementChild);
                frozenRow.appendChild(firstSwimlane.querySelector('.' + cls.SWIMLANE_HEADER_CLASS).cloneNode(true));
                this.addFrozenSwimlaneDataKey(firstSwimlane);
                ej2_base_1.setStyleAttribute(this.frozenSwimlaneRow, { height: ej2_base_1.formatUnit(firstSwimlane.getBoundingClientRect().height),
                    width: ej2_base_1.formatUnit(content.querySelector('.e-swimlane').getBoundingClientRect().width),
                    top: ej2_base_1.formatUnit(header.getBoundingClientRect().height.toString())
                });
                ej2_base_1.setStyleAttribute(header, { position: 'relative', top: ej2_base_1.formatUnit((-this.frozenSwimlaneRow.getBoundingClientRect().height)) });
                ej2_base_1.setStyleAttribute(content, { position: 'relative', top: ej2_base_1.formatUnit((-this.frozenSwimlaneRow.getBoundingClientRect().height)) });
            }
            else {
                var swimlaneRows = [].slice.call(this.parent.element.querySelectorAll('.' + cls.SWIMLANE_ROW_CLASS));
                var curSwim = swimlaneRows[this.frozenOrder];
                var prevSwim = swimlaneRows[this.frozenOrder - 1];
                var nextSwim = swimlaneRows[this.frozenOrder + 1];
                var curSwimHeight = void 0;
                var prevSwimHeight = void 0;
                var nextSwimHeight = void 0;
                Eif (curSwim) {
                    curSwimHeight = curSwim.getBoundingClientRect().top + curSwim.getBoundingClientRect().height;
                }
                Iif (prevSwim) {
                    prevSwimHeight = prevSwim.getBoundingClientRect().top + prevSwim.getBoundingClientRect().height;
                }
                Eif (nextSwim) {
                    nextSwimHeight = nextSwim.getBoundingClientRect().top + nextSwim.getBoundingClientRect().height;
                }
                var frozenSwimHeight = content.getBoundingClientRect().top + this.frozenSwimlaneRow.getBoundingClientRect().height;
                var frozenRowsElement = this.frozenSwimlaneRow.querySelector('.' + cls.FROZEN_ROW_CLASS);
                if (nextSwimHeight && frozenSwimHeight >= nextSwimHeight && this.frozenOrder < swimlaneRows.length - 1) {
                    Eif (frozenRowsElement) {
                        ej2_base_1.remove(frozenRowsElement.querySelector('.' + cls.SWIMLANE_HEADER_CLASS));
                        frozenRowsElement.appendChild(nextSwim.querySelector('.' + cls.SWIMLANE_HEADER_CLASS).cloneNode(true));
                        this.addFrozenSwimlaneDataKey(nextSwim);
                    }
                    ++this.frozenOrder;
                }
                else Iif (prevSwimHeight && frozenSwimHeight < curSwimHeight && frozenSwimHeight > prevSwimHeight && this.frozenOrder > 0) {
                    if (frozenRowsElement) {
                        ej2_base_1.remove(frozenRowsElement.querySelector('.' + cls.SWIMLANE_HEADER_CLASS));
                        frozenRowsElement.appendChild(prevSwim.querySelector('.' + cls.SWIMLANE_HEADER_CLASS).cloneNode(true));
                        this.addFrozenSwimlaneDataKey(prevSwim);
                    }
                    --this.frozenOrder;
                }
            }
            Iif (e && e.target.scrollTop == 0) {
                this.removeFrozenRows();
            }
        };
        LayoutRender.prototype.removeFrozenRows = function () {
            ej2_base_1.remove(this.frozenSwimlaneRow);
            this.frozenSwimlaneRow = null;
            var header = this.parent.element.querySelector('.' + cls.HEADER_CLASS);
            var content = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            ej2_base_1.setStyleAttribute(header, { position: '', top: '' });
            ej2_base_1.setStyleAttribute(content, { position: '', top: '' });
            this.parent.scrollPosition.content = { left: this.parent.scrollPosition.content.left, top: 0 };
            content.scrollTop = 0;
            this.frozenOrder = 0;
        };
        LayoutRender.prototype.onColumnScroll = function (e) {
            var target = e.target;
            Eif (target.offsetParent) {
                var columnKey = target.offsetParent.getAttribute('data-key');
                this.parent.scrollPosition.column[columnKey] = { left: target.scrollLeft, top: target.scrollTop };
            }
        };
        LayoutRender.prototype.onAdaptiveScroll = function (e) {
            if (this.parent.touchModule.tabHold && !this.parent.touchModule.mobilePopup) {
                e.preventDefault();
            }
        };
        LayoutRender.prototype.isColumnVisible = function (column) {
            var _this = this;
            var isVisible = false;
            var isNumeric = typeof column.keyField === 'number';
            if (isNumeric) {
                isVisible = this.parent.actionModule.hideColumnKeys.indexOf(column.keyField.toString()) === -1;
            }
            else {
                column.keyField.split(',').forEach(function (key) { isVisible = _this.parent.actionModule.hideColumnKeys.indexOf(key) === -1; });
            }
            return isVisible;
        };
        LayoutRender.prototype.renderLimits = function (column, target) {
            var limits = ej2_base_1.createElement('div', { className: cls.LIMITS_CLASS });
            Eif (column.minCount) {
                limits.appendChild(ej2_base_1.createElement('div', {
                    className: cls.MIN_COUNT_CLASS,
                    innerHTML: this.parent.localeObj.getConstant('min') + ': ' + column.minCount.toString()
                }));
            }
            Eif (column.maxCount) {
                limits.appendChild(ej2_base_1.createElement('div', {
                    className: cls.MAX_COUNT_CLASS,
                    innerHTML: this.parent.localeObj.getConstant('max') + ': ' + column.maxCount.toString()
                }));
            }
            Eif (limits.childElementCount > 0) {
                if (target.querySelector('.' + cls.CARD_WRAPPER_CLASS)) {
                    target.insertBefore(limits, target.firstElementChild);
                }
                else {
                    target.appendChild(limits);
                }
            }
        };
        LayoutRender.prototype.renderValidation = function () {
            var _this = this;
            this.parent.columns.forEach(function (column) {
                if (!column.minCount && !column.maxCount) {
                    return;
                }
                var cardData = _this.columnData[column.keyField];
                var keySelector = "[data-key=\"" + column.keyField + "\"]";
                var headerCell = _this.parent.element.querySelector("." + (cls.HEADER_CELLS_CLASS + keySelector));
                var rowCells = [].slice.call(_this.parent.element.querySelectorAll("." + (cls.CONTENT_CELLS_CLASS + keySelector)));
                if (_this.parent.constraintType === 'Swimlane' && _this.parent.swimlaneSettings.keyField) {
                    _this.swimlaneRow.forEach(function (row, index) {
                        _this.renderLimits(column, rowCells[index]);
                        var rowCards = cardData.filter(function (card) {
                            return card[_this.parent.swimlaneSettings.keyField] === row.keyField;
                        });
                        var colorClass = _this.getValidationClass(column, rowCards.length);
                        if (colorClass) {
                            ej2_base_1.addClass([rowCells[index]], colorClass);
                        }
                    });
                }
                else {
                    _this.renderLimits(column, headerCell);
                    var colorClass = _this.getValidationClass(column, cardData.length);
                    if (colorClass) {
                        ej2_base_1.addClass(rowCells.concat(headerCell), colorClass);
                    }
                }
            });
        };
        LayoutRender.prototype.getValidationClass = function (column, count) {
            var colorClass;
            if (column.maxCount && count > column.maxCount) {
                colorClass = cls.MAX_COLOR_CLASS;
            }
            else if (column.minCount && count < column.minCount) {
                colorClass = cls.MIN_COLOR_CLASS;
            }
            return colorClass;
        };
        LayoutRender.prototype.refreshValidation = function () {
            var validations = [].slice.call(this.parent.element.querySelectorAll('.' + cls.LIMITS_CLASS));
            validations.forEach(function (node) { ej2_base_1.remove(node); });
            var minClass = [].slice.call(this.parent.element.querySelectorAll('.' + cls.MIN_COLOR_CLASS));
            ej2_base_1.removeClass(minClass, cls.MIN_COLOR_CLASS);
            var maxClass = [].slice.call(this.parent.element.querySelectorAll('.' + cls.MAX_COLOR_CLASS));
            ej2_base_1.removeClass(maxClass, cls.MAX_COLOR_CLASS);
            this.renderValidation();
        };
        LayoutRender.prototype.getColumnData = function (columnValue, dataSource) {
            var _this = this;
            if (dataSource === void 0) { dataSource = this.parent.kanbanData; }
            var cardData = [];
            var isNumeric = typeof columnValue === 'number';
            if (isNumeric) {
                var keyData = dataSource.filter(function (cardObj) {
                    return cardObj[_this.parent.keyField] === columnValue;
                });
                cardData = cardData.concat(keyData);
            }
            else {
                var columnKeys = columnValue.split(',');
                var _loop_4 = function (key) {
                    var keyData = dataSource.filter(function (cardObj) {
                        return cardObj[_this.parent.keyField] === key.trim();
                    });
                    cardData = cardData.concat(keyData);
                };
                for (var _i = 0, columnKeys_1 = columnKeys; _i < columnKeys_1.length; _i++) {
                    var key = columnKeys_1[_i];
                    _loop_4(key);
                }
            }
            this.sortCategory(cardData);
            return cardData;
        };
        LayoutRender.prototype.sortCategory = function (cardData) {
            var key = this.parent.cardSettings.headerField;
            var direction = this.parent.sortSettings.direction;
            switch (this.parent.sortSettings.sortBy) {
                case 'DataSourceOrder':
                    this.sortOrder(key, direction, cardData);
                    break;
                case 'Custom':
                case 'Index':
                    if (this.parent.sortSettings.field) {
                        key = this.parent.sortSettings.field;
                    }
                    this.sortOrder(key, direction, cardData);
                    break;
            }
            return cardData;
        };
        LayoutRender.prototype.sortOrder = function (key, direction, cardData) {
            var isNumeric = true;
            if (this.parent.kanbanData.length > 0) {
                isNumeric = typeof (this.parent.kanbanData[0])[key] === 'number';
            }
            if (!isNumeric && this.parent.sortSettings.sortBy === 'Index') {
                return cardData;
            }
            var first;
            var second;
            cardData = cardData.sort(function (firstData, secondData) {
                if (!isNumeric) {
                    first = firstData[key].toLowerCase();
                    second = secondData[key].toLowerCase();
                }
                else {
                    first = firstData[key];
                    second = secondData[key];
                }
                return (first > second) ? 1 : ((second > first) ? -1 : 0);
            });
            if (direction === 'Descending') {
                cardData.reverse();
            }
            return cardData;
        };
        LayoutRender.prototype.documentClick = function (args) {
            Iif (args.target.classList.contains(cls.SWIMLANE_OVERLAY_CLASS) &&
                this.parent.element.querySelector('.' + cls.SWIMLANE_RESOURCE_CLASS).classList.contains('e-popup-open')) {
                this.treePopup.hide();
                ej2_base_1.removeClass([this.popupOverlay], 'e-enable');
            }
            Eif (ej2_base_1.closest(args.target, "." + cls.ROOT_CLASS)) {
                return;
            }
            var cards = [].slice.call(this.parent.element.querySelectorAll("." + cls.CARD_CLASS + "." + cls.CARD_SELECTION_CLASS));
            ej2_base_1.removeClass(cards, cls.CARD_SELECTION_CLASS);
            this.disableAttributeSelection(cards);
        };
        LayoutRender.prototype.disableAttributeSelection = function (cards) {
            if (cards instanceof Element) {
                cards.setAttribute('aria-selected', 'false');
            }
            else {
                cards.forEach(function (card) { card.setAttribute('aria-selected', 'false'); });
            }
        };
        LayoutRender.prototype.getColumnCards = function (data) {
            var _this = this;
            var columnData = {};
            this.columnKeys = [];
            this.parent.columns.forEach(function (column) {
                var isNumeric = typeof column.keyField === 'number';
                if (isNumeric) {
                    _this.columnKeys = _this.columnKeys.concat(column.keyField.toString());
                }
                else {
                    _this.columnKeys = _this.columnKeys.concat(column.keyField.split(',').map(function (e) { return e.trim(); }));
                }
                var cardData = _this.getColumnData(column.keyField, data);
                columnData[column.keyField] = cardData;
            });
            return columnData;
        };
        LayoutRender.prototype.getSwimlaneCards = function () {
            var _this = this;
            var swimlaneData = {};
            if (this.parent.swimlaneSettings.keyField) {
                this.kanbanRows.forEach(function (row) {
                    return swimlaneData[row.keyField] = _this.parent.kanbanData.filter(function (obj) {
                        return !ej2_base_1.isNullOrUndefined(obj[_this.parent.keyField]) && _this.columnKeys.indexOf(obj[_this.parent.keyField].toString()) > -1 &&
                            ((!obj[_this.parent.swimlaneSettings.keyField] && _this.parent.swimlaneSettings.showUnassignedRow) ?
                                '' : obj[_this.parent.swimlaneSettings.keyField]) === row.keyField;
                    });
                });
            }
            return swimlaneData;
        };
        LayoutRender.prototype.refreshHeaders = function () {
            var header = this.parent.element.querySelector('.' + cls.HEADER_CLASS);
            [].slice.call(header.children).forEach(function (child) { return ej2_base_1.remove(child); });
            this.renderHeader(header);
        };
        LayoutRender.prototype.refreshCards = function () {
            this.parent.resetTemplates(['cardTemplate']);
            var cards = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CARD_WRAPPER_CLASS));
            cards.forEach(function (card) { return ej2_base_1.remove(card); });
            this.renderCards();
            this.wireDragEvent();
            this.parent.renderTemplates();
        };
        LayoutRender.prototype.refresh = function () {
            var _this = this;
            var isColumnTemplateRefreshed = false;
            this.parent.columns.forEach(function (column) {
                Eif (column.showItemCount) {
                    if (column && column.template && !isColumnTemplateRefreshed) {
                        _this.refreshHeaders();
                        isColumnTemplateRefreshed = true;
                    }
                    var countSelector = "." + cls.HEADER_CELLS_CLASS + "[data-key=\"" + column.keyField + "\"] ." + cls.CARD_ITEM_COUNT_CLASS;
                    var itemCount = _this.parent.element.querySelector(countSelector);
                    if (itemCount) {
                        var isNumeric = typeof column.keyField === 'number';
                        var cardLength = 0;
                        if (isNumeric) {
                            cardLength = ([].slice.call(_this.parent.element.querySelectorAll('.' + cls.CARD_CLASS + '[data-key=\"' + column.keyField + '\"]'))).length;
                        }
                        else {
                            var keys = column.keyField.split(',');
                            for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
                                var key = keys_2[_i];
                                var cards = [].slice.call(_this.parent.element.querySelectorAll('.' + cls.CARD_CLASS + '[data-key=\"' + key.trim() + '\"]'));
                                cardLength = cards.length + cardLength;
                            }
                        }
                        itemCount.innerHTML = '- ' + cardLength + ' ' + _this.parent.localeObj.getConstant('items');
                    }
                }
            });
            if (this.parent.swimlaneSettings.keyField) {
                var swimlaneRows = [].slice.call(this.parent.element.querySelectorAll("." + cls.SWIMLANE_ROW_CLASS));
                swimlaneRows.forEach(function (swimlane) {
                    var swimlaneKey = swimlane.getAttribute('data-key');
                    var itemCount = swimlane.querySelector("." + cls.CARD_ITEM_COUNT_CLASS);
                    Eif (itemCount && swimlaneKey) {
                        var cards = [].slice.call(swimlane.nextElementSibling.querySelectorAll('.' + cls.CARD_CLASS));
                        itemCount.innerHTML = '- ' + cards.length + ' ' + _this.parent.localeObj.getConstant('items');
                    }
                });
            }
            this.refreshValidation();
        };
        LayoutRender.prototype.updateScrollPosition = function () {
            var _this = this;
            var content = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            Eif (content) {
                Eif (!ej2_base_1.Browser.isIE) {
                    content.scrollTo(this.parent.scrollPosition.content.left, this.parent.scrollPosition.content.top);
                }
                else {
                    content.scrollTop = this.parent.scrollPosition.content.top;
                    content.scrollLeft = this.parent.scrollPosition.content.left;
                }
            }
            var cardWrapper = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CARD_WRAPPER_CLASS));
            cardWrapper.forEach(function (wrapper) {
                if (wrapper.offsetParent) {
                    var scrollData = _this.parent.scrollPosition.column[wrapper.offsetParent.getAttribute('data-key')];
                    if (scrollData) {
                        Eif (!ej2_base_1.Browser.isIE) {
                            wrapper.scrollTo(scrollData.left, scrollData.top);
                        }
                        else {
                            wrapper.scrollTop = scrollData.top;
                            wrapper.scrollLeft = scrollData.left;
                        }
                    }
                }
            });
        };
        LayoutRender.prototype.renderCardBasedOnIndex = function (data, index) {
            var _this = this;
            var key = data[this.parent.keyField];
            var cardRow = this.parent.element.querySelector('.e-content-row:not(.e-swimlane-row)');
            if (this.parent.swimlaneSettings.keyField && !this.parent.isAdaptive) {
                var rowSelector = ".e-content-row.e-swimlane-row[data-key=\"" + data[this.parent.swimlaneSettings.keyField] + "\"]";
                if (this.parent.element.querySelector(rowSelector)) {
                    cardRow = this.parent.element.querySelector(rowSelector).nextElementSibling;
                }
                else {
                    var columnIndex = this.columnKeys.indexOf(key);
                    Eif (columnIndex !== -1 && this.parent.actionModule.hideColumnKeys.indexOf(key) === -1) {
                        var index_1 = this.kanbanRows.findIndex(function (rowData) { return rowData['keyField'] === data[_this.parent.swimlaneSettings.keyField]; });
                        var swim = [].slice.call(this.parent.element.querySelectorAll('.e-swimlane-row'));
                        var swimRow = this.parent.element.querySelector('.' + cls.CONTENT_TABLE_CLASS + ' tbody');
                        Eif (swim[index_1]) {
                            swimRow = swim[index_1];
                        }
                        this.renderSwimlaneRow(swimRow, this.kanbanRows[index_1], false);
                        this.renderSingleContent(swimRow, this.kanbanRows[index_1], false);
                    }
                    cardRow = this.parent.element.querySelector(rowSelector).nextElementSibling;
                    [].slice.call(cardRow.children).forEach(function (cell) {
                        var cardWrapper = ej2_base_1.createElement('div', { className: cls.CARD_WRAPPER_CLASS });
                        cell.appendChild(cardWrapper);
                        cardWrapper.appendChild(_this.renderEmptyCard());
                    });
                }
            }
            if (this.parent.sortSettings.sortBy !== 'Index') {
                var field_1 = this.parent.cardSettings.headerField;
                if (this.parent.sortSettings.sortBy === 'Custom') {
                    field_1 = this.parent.sortSettings.field;
                }
                if (ej2_base_1.isNullOrUndefined(this.parent.swimlaneSettings.keyField)) {
                    index = this.getColumnData(key, this.parent.kanbanData).findIndex(function (colData) {
                        return colData[field_1] === data[field_1];
                    });
                }
                else {
                    var swimlaneDatas = this.parent.getSwimlaneData(data[this.parent.swimlaneSettings.keyField]);
                    index = this.getColumnData(key, swimlaneDatas).findIndex(function (colData) { return colData[field_1] === data[field_1]; });
                }
            }
            else if (this.parent.sortSettings.sortBy === 'Index' &&
                this.parent.sortSettings.field && this.parent.sortSettings.direction === 'Ascending') {
                index = data[this.parent.sortSettings.field] - 1;
            }
            Eif (cardRow) {
                var td = [].slice.call(cardRow.children).filter(function (e) {
                    return e.getAttribute('data-key').replace(/\s/g, '').split(',').indexOf(key.toString().replace(/\s/g, '')) !== -1;
                })[0];
                var cardWrapper_2 = td.querySelector('.' + cls.CARD_WRAPPER_CLASS);
                var emptyCard = cardWrapper_2.querySelector('.' + cls.EMPTY_CARD_CLASS);
                if (emptyCard) {
                    ej2_base_1.remove(emptyCard);
                }
                var cardElement_1 = this.renderCard(data);
                Eif (this.parent.allowDragAndDrop && td.classList.contains(cls.DRAG_CLASS)) {
                    this.parent.dragAndDropModule.wireDragEvents(cardElement_1);
                    ej2_base_1.addClass([cardElement_1], cls.DROPPABLE_CLASS);
                }
                var args = { data: data, element: cardElement_1, cancel: false };
                this.parent.trigger(events.cardRendered, args, function (cardArgs) {
                    Eif (!cardArgs.cancel) {
                        if (ej2_base_1.isNullOrUndefined(index) || cardWrapper_2.children.length === 0) {
                            cardWrapper_2.appendChild(cardElement_1);
                        }
                        else {
                            cardWrapper_2.insertBefore(cardElement_1, cardWrapper_2.childNodes[index]);
                        }
                    }
                });
            }
        };
        LayoutRender.prototype.removeCard = function (data) {
            var cardKey = data[this.parent.cardSettings.headerField];
            var cardElement = this.parent.element.querySelector("." + cls.CARD_CLASS + "[data-id=\"" + cardKey + "\"]");
            this.isSelectedCard = cardElement.classList.contains(cls.CARD_SELECTION_CLASS) ? true : false;
            var cardContainer = cardElement.parentElement;
            Eif (cardElement) {
                ej2_base_1.remove(cardElement);
            }
            if (cardContainer.querySelectorAll('.' + cls.CARD_CLASS + ':not(.' + cls.CLONED_CARD_CLASS + ')').length === 0) {
                cardContainer.appendChild(this.renderEmptyCard());
            }
        };
        LayoutRender.prototype.wireEvents = function () {
            var _this = this;
            ej2_base_1.EventHandler.add(this.parent.element, 'click', this.parent.actionModule.clickHandler, this.parent.actionModule);
            ej2_base_1.EventHandler.add(this.parent.element, 'dblclick', this.parent.actionModule.doubleClickHandler, this.parent.actionModule);
            ej2_base_1.EventHandler.add(document, ej2_base_1.Browser.touchStartEvent, this.documentClick, this);
            var content = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            ej2_base_1.EventHandler.add(content, 'scroll', this.onContentScroll, this);
            var cardWrapper = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CARD_WRAPPER_CLASS));
            cardWrapper.forEach(function (wrapper) {
                if (_this.parent.isInitialRender && wrapper.offsetParent) {
                    _this.parent.scrollPosition.column[wrapper.offsetParent.getAttribute('data-key')] = { left: 0, top: 0 };
                }
                ej2_base_1.EventHandler.add(wrapper, 'scroll', _this.onColumnScroll, _this);
            });
            if (this.parent.isAdaptive) {
                this.parent.touchModule.wireTouchEvents();
                content.scrollLeft = this.scrollLeft;
            }
            this.wireDragEvent();
        };
        LayoutRender.prototype.unWireEvents = function () {
            var _this = this;
            ej2_base_1.EventHandler.remove(this.parent.element, 'click', this.parent.actionModule.clickHandler);
            ej2_base_1.EventHandler.remove(this.parent.element, 'dblclick', this.parent.actionModule.doubleClickHandler);
            ej2_base_1.EventHandler.remove(document, ej2_base_1.Browser.touchStartEvent, this.documentClick);
            var content = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            if (content) {
                ej2_base_1.EventHandler.remove(content, 'scroll', this.onContentScroll);
                if (this.parent.allowDragAndDrop) {
                    this.unWireDragEvent();
                }
            }
            var cardWrapper = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CARD_WRAPPER_CLASS));
            cardWrapper.forEach(function (wrapper) { ej2_base_1.EventHandler.remove(wrapper, 'scroll', _this.onColumnScroll); });
            if (this.parent.isAdaptive) {
                this.parent.touchModule.unWireTouchEvents();
            }
        };
        LayoutRender.prototype.wireDragEvent = function () {
            var _this = this;
            if (this.parent.allowDragAndDrop) {
                var cards = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CONTENT_CELLS_CLASS
                    + '.' + cls.DRAG_CLASS + ' .' + cls.CARD_CLASS));
                ej2_base_1.addClass(cards, cls.DROPPABLE_CLASS);
                cards.forEach(function (card) { return _this.parent.dragAndDropModule.wireDragEvents(card); });
            }
        };
        LayoutRender.prototype.unWireDragEvent = function () {
            var _this = this;
            var cards = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CONTENT_CELLS_CLASS
                + '.' + cls.DRAG_CLASS + ' .' + cls.CARD_CLASS));
            ej2_base_1.removeClass(cards, cls.DROPPABLE_CLASS);
            cards.forEach(function (card) { return _this.parent.dragAndDropModule.unWireDragEvents(card); });
        };
        LayoutRender.prototype.destroy = function () {
            this.parent.resetTemplates();
            this.parent.off(events.dataReady, this.initRender);
            this.parent.off(events.contentReady, this.scrollUiUpdate);
            this.unWireEvents();
            var header = this.parent.element.querySelector('.' + cls.HEADER_CLASS);
            if (header) {
                ej2_base_1.remove(header);
            }
            var content = this.parent.element.querySelector('.' + cls.CONTENT_CLASS);
            if (content) {
                ej2_base_1.remove(content);
            }
            if (this.treeViewObj) {
                this.treeViewObj.destroy();
                this.treeViewObj = null;
            }
            if (this.treePopup) {
                this.treePopup.destroy();
                this.treePopup = null;
            }
            var swimlaneToolBarEle = this.parent.element.querySelector('.' + cls.SWIMLANE_HEADER_CLASS);
            if (swimlaneToolBarEle) {
                ej2_base_1.remove(swimlaneToolBarEle);
            }
            var swimlaneContent = this.parent.element.querySelector('.' + cls.SWIMLANE_CONTENT_CLASS);
            if (swimlaneContent) {
                ej2_base_1.remove(swimlaneContent);
            }
        };
        return LayoutRender;
    }(mobile_layout_1.MobileLayout));
    exports.LayoutRender = LayoutRender;
});