all files / base/ tree-grid.js

92.34% Statements 711/770
85.54% Branches 568/664
91.89% Functions 68/74
92.33% Lines 710/769
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 1128 1129 1130 1131 1132 1133 1134 1135 1136   1137× 1137× 1137× 1137× 164957×   1137× 10244×   1137× 23999×   1137×                   1137×   1137× 17×   17×   17×                     1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1134×   1137× 1137×   1137×   1137× 1137× 1137× 1137×         1137×     1137× 1137× 1137× 1137×   1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137×   1137×   1137× 1137× 1137× 1137× 1137× 1137× 1137× 78×   1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137×     1135×       1135× 1135×     1137× 1137× 1137× 1137× 1137× 1137× 84×   1137× 1137× 1137×     1367×   1367×   1367× 1367× 1367× 1367× 1367× 1367× 1367× 1367× 1367× 1367×   1367× 1367× 1367× 1367× 1367× 1367×         1367×       1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137×   1554×       1554×   1554× 71×   1554×   1365× 1365× 1365×           1365×   169×         169×   32× 32× 32× 32× 22× 14× 217× 217×   14×           24× 24× 24× 24× 18× 128× 128×             31× 20× 20× 20× 20× 13× 167× 167×         20×       31×       31×   31×   24× 17× 17× 17× 17× 78× 78×         17×       24×       24×   24× 24×   812× 17×   812× 812× 812× 478×   812× 812× 628×     623×       1137×     623× 623× 623× 623× 590× 590× 590× 590×     33× 33× 33× 33× 33×     436× 436× 436×         436× 11×         436× 12×             12× 12×   424×         415× 157× 157× 157× 157× 157× 50×     157× 157× 157×     436× 22×   436×           436×     436×   436× 88× 24×                         24× 24×         64×                                   64× 64× 64× 4067×   50×     64× 64×   88× 88×   88×   436× 80×   436× 436× 30×         436×     434×     1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137×   1137× 1137× 1137×   1137×     1137×   1137× 1137×   1137× 16×     40× 40× 17×   40× 40×     1139× 1139× 1139× 1139× 1139× 1139× 1139×   1139× 3884× 3884×       3884×   3884× 3884× 3884× 50560×     3884× 340× 74×   266× 266× 266× 266× 266× 266× 266×     3544× 3544× 3544× 3544×     1139× 1139× 3884×   1139× 14680× 14680× 5172× 5172× 5172×     1139× 109× 109× 109×     8825× 8825× 8825× 33762×   8825× 8825× 7687×   8825× 1138×   7687× 1139×       1139×   1139× 1139× 1139×   6548× 1129×       1129×   1129×   1129× 1129× 1129× 11×     1118×     1117×       5419× 896×       896×   896× 896×   896× 896×     887×       887×       4523× 1116× 1116×       1116×   1116×     1116× 1116×   3407× 1085×   2322× 835×       835×   835× 835× 835× 835× 835× 835× 11×                                   1487× 304×   1183× 132×       132×   132× 132× 132× 132× 124×         1051×   582×   582× 582×       582×   582× 582×     469× 136×       136×   136× 136× 136×   333× 41×       41×   41× 41× 41×   292× 42×       42×   42× 42× 42× 42×                     8825×   156× 156× 28× 28× 28× 36× 24× 24×   12×         28×       11× 11× 11× 11× 11× 15×   12×                 304× 1827×   304×       304×   304× 304× 304× 304×   10× 10× 10×           1138× 1138× 1138× 1138× 1138×             1134×   1138× 1138× 1106× 1102× 1102×     1138× 74× 14×     60×   74×     1064× 1064×   1138×   109× 109× 109× 109× 109×   1085× 3674×   1085×       1085×   1085× 1085×   9091× 9091× 9091× 68657× 68657×   9091× 9091× 9091× 7712×     23532× 23530× 23530×         14227× 14227× 6408× 6408× 6408× 6408× 7956× 6931× 6931×   1025× 119× 119×   906× 140× 140×   766× 103× 103×     6408×   7819×   3433× 3433× 3433×       3263× 3263× 3263×       1098× 1098× 1098×       387× 185×     202×     3137×         1137× 1137× 1137× 1137×   1137× 1137× 1137× 1137×          
define(["require", "exports", "@syncfusion/ej2-treegrid", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-data", "../models/column", "./utils", "@syncfusion/ej2-dropdowns"], function (require, exports, ej2_treegrid_1, ej2_base_1, ej2_base_2, ej2_data_1, column_1, utils_1, ej2_dropdowns_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var GanttTreeGrid = (function () {
        function GanttTreeGrid(parent) {
            var _this = this;
            this.isPersist = false;
            this.previousScroll = { top: 0, left: 0 };
            this.queryCellInfo = function (args) {
                _this.parent.trigger('queryCellInfo', args);
            };
            this.headerCellInfo = function (args) {
                _this.parent.trigger('headerCellInfo', args);
            };
            this.rowDataBound = function (args) {
                _this.parent.trigger('rowDataBound', args);
            };
            this.columnMenuOpen = function (args) {
                _this.parent.notify('columnMenuOpen', args);
                _this.parent.trigger('columnMenuOpen', args);
                document.querySelector('.e-colmenu').addEventListener('mousemove', function () {
                    var filPopOptions = document.querySelector('.e-filter-popup');
                    var filOptions = document.querySelector('.e-filter-item');
                    if (!ej2_base_1.isNullOrUndefined(filPopOptions)) {
                        if (!filOptions.classList.contains('e-focused')) {
                            ej2_base_1.remove(_this.parent.filterModule.filterMenuElement);
                        }
                    }
                });
            };
            this.columnMenuClick = function (args) {
                _this.parent.trigger('columnMenuClick', args);
            };
            this.objectEqualityChecker = function (old, current) {
                Eif (old) {
                    var keys = Object.keys(old);
                    var isEqual = true;
                    var excludeKeys = ['Children', 'childRecords', 'taskData', 'uniqueID', 'parentItem', 'parentUniqueID', 'ganttProperties'];
                    for (var i = 0; i < keys.length; i++) {
                        var oldKey = old[keys[parseInt(i.toString(), 10)]] instanceof Date ?
                            new Date(old[keys[parseInt(i.toString(), 10)]]).getTime() : old[keys[parseInt(i.toString(), 10)]];
                        var currentKey = current[keys[parseInt(i.toString(), 10)]] instanceof Date ?
                            new Date(current[keys[parseInt(i.toString(), 10)]]).getTime() : current[keys[parseInt(i.toString(), 10)]];
                        Iif (oldKey !== currentKey && excludeKeys.indexOf(keys[i]) === -1) {
                            _this.parent.modifiedRecords.push(current);
                            isEqual = false;
                            break;
                        }
                    }
                    return isEqual;
                }
                else {
                    return false;
                }
            };
            this.parent = parent;
            this.parent.treeGrid = new ej2_treegrid_1.TreeGrid();
            this.parent.treeGrid.allowSelection = false;
            this.parent.treeGrid.allowKeyboard = this.parent.allowKeyboard;
            this.parent.treeGrid['${enableHtmlSanitizer}'] = this.parent.enableHtmlSanitizer;
            this.parent.treeGrid.enableImmutableMode = this.parent.enableImmutableMode;
            this.treeGridColumns = [];
            if (!this.parent.isLocaleChanged && this.parent.isLoad) {
                this.parent.previousGanttColumns = ej2_base_1.extend([], [], this.parent.columns, true);
            }
            this.validateGanttColumns();
            if (this.parent.isLocaleChanged) {
                this.parent.isLocaleChanged = false;
            }
            this.addEventListener();
        }
        GanttTreeGrid.prototype.addEventListener = function () {
            this.parent.on('renderPanels', this.createContainer, this);
            this.parent.on('chartScroll', this.updateScrollTop, this);
            this.parent.on('destroy', this.destroy, this);
            this.parent.treeGrid.on('renderReactTemplate', this.renderReactTemplate, this);
        };
        GanttTreeGrid.prototype.renderReactTemplate = function (args) {
            var portals = 'portals';
            for (var _i = 0, args_1 = args; _i < args_1.length; _i++) {
                var portal = args_1[_i];
                Eif (this.parent[portals].indexOf(portal) === -1) {
                    this.parent[portals].push(portal);
                }
            }
            this.parent.renderTemplates();
        };
        GanttTreeGrid.prototype.createContainer = function () {
            this.treeGridElement = ej2_base_1.createElement('div', {
                id: 'treeGrid' + this.parent.element.id, className: 'e-gantt-tree-grid'
            });
            var tempHeader = ej2_base_1.createElement('div', { className: 'e-gantt-temp-header' });
            this.parent.treeGridPane.appendChild(this.treeGridElement);
            this.treeGridElement.appendChild(tempHeader);
            this.parent.treeGridPane.classList.add('e-temp-content');
        };
        GanttTreeGrid.prototype.renderTreeGrid = function () {
            this.composeProperties();
            this.bindEvents();
            var root = 'root';
            this.parent.treeGrid[root] = this.parent[root] ? this.parent[root] : this.parent;
            ej2_base_2.setValue('registeredTemplate', this.registeredTemplate, this.parent.treeGrid);
            var ref = 'viewContainerRef';
            ej2_base_2.setValue('viewContainerRef', this.parent["" + ref], this.parent.treeGrid);
            this.parent.treeGrid.appendTo(this.treeGridElement);
            if (this.parent.treeGrid.grid && this.parent.toolbarModule && this.parent.isReact) {
                this.parent.treeGrid.grid.portals = this.parent.portals;
            }
            this.wireEvents();
        };
        GanttTreeGrid.prototype.composeProperties = function () {
            this.parent.treeGrid.enableAdaptiveUI = this.parent.enableAdaptiveUI;
            this.parent.treeGrid.hasChildMapping = this.parent.taskFields.hasChildMapping;
            this.parent.treeGrid.query = this.parent.query;
            this.parent.treeGrid.loadChildOnDemand = this.parent.loadChildOnDemand;
            this.parent.treeGrid['isFromGantt'] = true;
            this.parent.treeGrid.parentIdMapping = this.parent.taskFields.parentID;
            if (this.parent.taskFields.parentID) {
                this.parent.treeGrid.idMapping = this.parent.taskFields.id;
            }
            this.parent.treeGrid.showColumnMenu = this.parent.showColumnMenu;
            this.parent.treeGrid.enableCollapseAll = this.parent.collapseAllParentTasks;
            this.parent.treeGrid.columnMenuItems = this.parent.columnMenuItems;
            this.parent.treeGrid.enableRtl = this.parent.enableRtl;
            this.parent.treeGrid.childMapping = ej2_base_1.isNullOrUndefined(this.parent.taskFields.child) ? '' : this.parent.taskFields.child;
            this.parent.treeGrid.treeColumnIndex = this.parent.treeColumnIndex;
            this.parent.treeGrid.columns = this.treeGridColumns;
            this.parent.treeGrid.loadingIndicator = this.parent.loadingIndicator;
            this.parent.treeGrid.enableVirtualMaskRow = this.parent.enableVirtualMaskRow;
            if (this.parent.dataSource instanceof Object && utils_1.isCountRequired(this.parent)) {
                this.parent.treeGrid.hasChildMapping = 'isParent';
                var count = ej2_base_1.getValue('count', this.parent.dataSource);
                this.parent.treeGrid.dataSource = { result: this.parent.flatData, count: count };
            }
            else {
                Iif (this.parent.treeGrid.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                    this.parent.treeGrid.dataSource = this.parent.dataSource;
                }
                else {
                    this.parent.treeGrid.hasChildMapping = null;
                    this.parent.treeGrid.dataSource = this.parent.flatData;
                }
            }
            this.parent.treeGrid.expandStateMapping = this.parent.taskFields.expandState;
            var isGantt = 'isGantt';
            this.parent.treeGrid[isGantt] = true;
            this.parent.treeGrid.rowHeight = this.parent.rowHeight;
            this.parent.treeGrid.gridLines = this.parent.gridLines;
            if (this.parent.searchSettings.fields.length !== 0 || this.parent.searchSettings.key !== '') {
                this.parent.treeGrid.searchSettings = this.parent.searchSettings;
            }
            var isJsComponent = 'isJsComponent';
            this.parent.treeGrid[isJsComponent] = true;
            this.parent.treeGrid.height =
                this.parent.element.getElementsByClassName('e-chart-scroll-container e-content')[0]['offsetHeight'] - (this.parent.flatData.length === 0 ? 0 : 19);
        };
        GanttTreeGrid.prototype.getContentDiv = function () {
            return this.treeGridElement.querySelector('.e-content');
        };
        GanttTreeGrid.prototype.getHeaderDiv = function () {
            return this.treeGridElement.querySelector('.e-headercontent');
        };
        GanttTreeGrid.prototype.getScrollbarWidth = function () {
            var outer = document.createElement('div');
            outer.style.visibility = 'hidden';
            outer.style.overflow = 'scroll';
            outer.style.msOverflowStyle = 'scrollbar';
            var inner = document.createElement('div');
            outer.appendChild(inner);
            this.parent.element.appendChild(outer);
            var scrollbarWidth = (outer.offsetWidth - inner.offsetWidth);
            outer.parentNode.removeChild(outer);
            return scrollbarWidth;
        };
        GanttTreeGrid.prototype.ensureScrollBar = function () {
            var content = this.getContentDiv();
            var headerDiv = this.getHeaderDiv();
            var scrollWidth = this.getScrollbarWidth();
            var isMobile = /Android|Mac|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
            Eif (scrollWidth !== 0) {
                content.style.cssText += 'width: calc(100% + ' + (scrollWidth + 1) + 'px);';
            }
            else {
                content.classList.add('e-gantt-scroll-padding');
            }
            Iif (scrollWidth === 0 && isMobile) {
                headerDiv.style.cssText += 'width: calc(100% + 17px);';
            }
        };
        GanttTreeGrid.prototype.bindEvents = function () {
            this.parent.treeGrid.dataBound = this.dataBound.bind(this);
            this.parent.treeGrid.collapsing = this.collapsing.bind(this);
            this.parent.treeGrid.collapsed = this.collapsed.bind(this);
            this.parent.treeGrid.expanding = this.expanding.bind(this);
            this.parent.treeGrid.expanded = this.expanded.bind(this);
            this.parent.treeGrid.actionBegin = this.actionBegin.bind(this);
            this.parent.treeGrid.actionComplete = this.treeActionComplete.bind(this);
            this.parent.treeGrid.created = this.created.bind(this);
            this.parent.treeGrid.actionFailure = this.actionFailure.bind(this);
            this.parent.treeGrid.queryCellInfo = this.queryCellInfo.bind(this);
            this.parent.treeGrid.headerCellInfo = this.headerCellInfo.bind(this);
            this.parent.treeGrid.rowDataBound = this.rowDataBound.bind(this);
            this.parent.treeGrid.columnMenuOpen = this.columnMenuOpen.bind(this);
            this.parent.treeGrid.columnMenuClick = this.columnMenuClick.bind(this);
            this.parent.treeGrid.beforeDataBound = this.beforeDataBound.bind(this);
            this.parent.treeGrid.dataStateChange = this.dataStateChange.bind(this);
        };
        GanttTreeGrid.prototype.beforeDataBound = function (args) {
            if (!ej2_base_1.isNullOrUndefined(this.parent.selectionModule) && this.parent.selectionSettings &&
                this.parent.selectionSettings.persistSelection && this.parent.selectionModule.getSelectedRowIndexes().length > 0 &&
                args['actionArgs']['requestType'] === 'sorting') {
                this.isPersist = true;
            }
            this.parent.updatedRecords = this.parent.virtualScrollModule && this.parent.enableVirtualization ?
                ej2_base_1.getValue('virtualScrollModule.visualData', this.parent.treeGrid) : ej2_base_1.getValue('result', args);
            if (this.parent.virtualScrollModule && this.parent.enableVirtualization) {
                this.parent.updateContentHeight(args);
            }
            ej2_base_2.setValue('contentModule.objectEqualityChecker', this.objectEqualityChecker, this.parent.treeGrid.grid);
        };
        GanttTreeGrid.prototype.dataBound = function (args) {
            this.ensureScrollBar();
            this.parent.treeDataBound(args);
            if (this.parent.isVirtualScroll) {
                Eif ((this.parent.enableVirtualMaskRow && this.parent.enableVirtualization) ||
                    (this.parent.enableVirtualization && !this.parent.enableVirtualMaskRow && this.parent.loadingIndicator.indicatorType === 'Shimmer') ||
                    (this.parent.loadingIndicator.indicatorType === 'Shimmer')) {
                    this.parent.hideMaskRow();
                }
                this.parent.isVirtualScroll = false;
                Eif (!ej2_base_1.isNullOrUndefined(this.parent.selectionModule) && !ej2_base_1.isNullOrUndefined(this.parent.toolbarModule)) {
                    this.parent.toolbarModule.refreshToolbarItems();
                }
            }
            this.prevCurrentView = ej2_base_1.extend([], [], this.parent.currentViewData, true);
        };
        GanttTreeGrid.prototype.dataStateChange = function (args) {
            if (args.action && args.action.requestType === 'refresh') {
                this.parent.treeGrid.dataSource = {
                    result: ej2_base_1.getValue('result', this.parent.treeGrid.dataSource),
                    count: ej2_base_1.getValue('count', this.parent.treeGrid.dataSource)
                };
            }
            this.parent.trigger('dataStateChange', args);
        };
        GanttTreeGrid.prototype.collapsing = function (args) {
            var collapsingArgs;
            var record = ej2_base_1.getValue('data', args);
            var recordLength = record.length;
            if (!this.parent.ganttChartModule.isExpandCollapseFromChart) {
                if (!ej2_base_1.isNullOrUndefined(recordLength)) {
                    for (var i = 0; i < recordLength; i++) {
                        collapsingArgs = this.createExpandCollapseArgs(args, record[i]);
                        this.parent.ganttChartModule.collapseGanttRow(collapsingArgs);
                    }
                    ej2_base_2.setValue('cancel', ej2_base_1.getValue('cancel', collapsingArgs), args);
                }
                else {
                    collapsingArgs = this.createExpandCollapseArgs(args, null);
                    this.parent.ganttChartModule.collapseGanttRow(collapsingArgs);
                    ej2_base_2.setValue('cancel', ej2_base_1.getValue('cancel', collapsingArgs), args);
                }
            }
        };
        GanttTreeGrid.prototype.expanding = function (args) {
            var expandingArgs;
            var record = ej2_base_1.getValue('data', args);
            var recordLength = record.length;
            if (!this.parent.ganttChartModule.isExpandCollapseFromChart) {
                if (!ej2_base_1.isNullOrUndefined(recordLength)) {
                    for (var i = 0; i < recordLength; i++) {
                        expandingArgs = this.createExpandCollapseArgs(args, record[i]);
                        this.parent.ganttChartModule.expandGanttRow(expandingArgs);
                    }
                    ej2_base_2.setValue('cancel', ej2_base_1.getValue('cancel', expandingArgs), args);
                }
                else {
                    expandingArgs = this.createExpandCollapseArgs(args, null);
                    this.parent.ganttChartModule.expandGanttRow(expandingArgs);
                    ej2_base_2.setValue('cancel', ej2_base_1.getValue('cancel', expandingArgs), args);
                }
            }
        };
        GanttTreeGrid.prototype.collapsed = function (args) {
            if (!this.parent.ganttChartModule.isExpandCollapseFromChart && !this.parent.isExpandCollapseLevelMethod) {
                var collapsedArgs = void 0;
                var record = ej2_base_1.getValue('data', args);
                var recordLength = record.length;
                if (!ej2_base_1.isNullOrUndefined(recordLength)) {
                    for (var i = 0; i < recordLength; i++) {
                        collapsedArgs = this.createExpandCollapseArgs(args, record[i]);
                        this.parent.ganttChartModule.collapsedGanttRow(collapsedArgs);
                    }
                }
                else {
                    collapsedArgs = this.createExpandCollapseArgs(args, null);
                    this.parent.ganttChartModule.collapsedGanttRow(collapsedArgs);
                }
                if (!this.parent.ganttChartModule.isCollapseAll && collapsedArgs['gridRow'] && !this.parent.allowTaskbarOverlap) {
                    collapsedArgs['gridRow'].style.height = collapsedArgs['chartRow'].style.height;
                    this.parent.contentHeight = this.parent.enableRtl ? this.parent['element'].getElementsByClassName('e-content')[2].children[0]['offsetHeight'] :
                        this.parent['element'].getElementsByClassName('e-content')[0].children[0]['offsetHeight'];
                    document.getElementsByClassName('e-chart-rows-container')[0]['style'].height = this.parent.contentHeight + 'px';
                }
            }
            Iif (!ej2_base_1.isNullOrUndefined(this.parent.loadingIndicator) && this.parent.loadingIndicator.indicatorType === 'Shimmer') {
                this.parent.hideMaskRow();
            }
            else {
                this.parent.hideSpinner();
            }
            this.parent.trigger('collapsed', args);
        };
        GanttTreeGrid.prototype.expanded = function (args) {
            if (!this.parent.ganttChartModule.isExpandCollapseFromChart && !this.parent.isExpandCollapseLevelMethod) {
                var expandedArgs = void 0;
                var record = ej2_base_1.getValue('data', args);
                var recordLength = record.length;
                if (!ej2_base_1.isNullOrUndefined(recordLength)) {
                    for (var i = 0; i < recordLength; i++) {
                        expandedArgs = this.createExpandCollapseArgs(args, record[i]);
                        this.parent.ganttChartModule.expandedGanttRow(expandedArgs);
                    }
                }
                else {
                    expandedArgs = this.createExpandCollapseArgs(args, null);
                    this.parent.ganttChartModule.expandedGanttRow(expandedArgs);
                }
                if (!this.parent.ganttChartModule.isExpandAll && args['row'] && !this.parent.allowTaskbarOverlap) {
                    args['row'].style.height = this.parent.rowHeight + 'px';
                    this.parent.contentHeight = this.parent.enableRtl ? this.parent['element'].getElementsByClassName('e-content')[2].children[0]['offsetHeight'] :
                        this.parent['element'].getElementsByClassName('e-content')[0].children[0]['offsetHeight'];
                    document.getElementsByClassName('e-chart-rows-container')[0]['style'].height = this.parent.contentHeight + 'px';
                }
            }
            Iif (!ej2_base_1.isNullOrUndefined(this.parent.loadingIndicator) && this.parent.loadingIndicator.indicatorType === 'Shimmer') {
                this.parent.hideMaskRow();
            }
            else {
                this.parent.hideSpinner();
            }
            this.parent.isCollapseAll = false;
            this.parent.trigger('expanded', args);
        };
        GanttTreeGrid.prototype.actionBegin = function (args) {
            if (this.parent.undoRedoModule && (args.requestType === 'filtering' || args.requestType === 'searching' || args.requestType === 'sorting' || args.requestType === 'filterAfterOpen')) {
                this.parent.undoRedoModule['canUpdateIndex'] = false;
            }
            this.parent.notify('actionBegin', args);
            var flag = ej2_base_1.getValue('doubleClickTarget', this.parent.treeGrid.editModule);
            if (flag !== null) {
                ej2_base_2.setValue('doubleClickTarget', null, this.parent.treeGrid.editModule);
            }
            this.parent.trigger('actionBegin', args);
            if (args.requestType !== 'virtualscroll' && args.type !== 'edit' && args.requestType !== 'beginEdit' && !args.cancel) {
                if (!ej2_base_1.isNullOrUndefined(this.parent.loadingIndicator) && this.parent.loadingIndicator.indicatorType === 'Shimmer') {
                    this.parent.showMaskRow();
                }
                else {
                    this.parent.showSpinner();
                }
            }
        };
        GanttTreeGrid.prototype.created = function (args) {
            this.updateKeyConfigSettings();
        };
        GanttTreeGrid.prototype.actionFailure = function (args) {
            this.parent.trigger('actionFailure', args);
        };
        GanttTreeGrid.prototype.createExpandCollapseArgs = function (args, currentRecord) {
            var chartRow;
            var record = ej2_base_1.getValue('data', args);
            var recordLength = record.length;
            if (!ej2_base_1.isNullOrUndefined(recordLength)) {
                var gridRow = ej2_base_1.getValue('row', args);
                chartRow = this.parent.ganttChartModule.getChartRows()[this.parent.currentViewData.indexOf(currentRecord)];
                var eventArgs = { data: currentRecord, gridRow: gridRow, chartRow: chartRow, cancel: false };
                return eventArgs;
            }
            else {
                var recordOne = ej2_base_1.getValue('data', args);
                var gridRow = ej2_base_1.getValue('row', args);
                chartRow = this.parent.ganttChartModule.getChartRows()[this.parent.currentViewData.indexOf(recordOne)];
                var eventArgs = { data: recordOne, gridRow: gridRow, chartRow: chartRow, cancel: false };
                return eventArgs;
            }
        };
        GanttTreeGrid.prototype.treeActionComplete = function (args) {
            var _this = this;
            var updatedArgs = ej2_base_1.extend({}, args);
            if (ej2_base_1.getValue('requestType', args) === 'reorder') {
                if (this.parent.undoRedoModule && !this.parent.undoRedoModule['isFromUndoRedo'] && this.parent['isUndoRedoItemPresent']('ColumnReorder')) {
                    Iif (this.parent.undoRedoModule['redoEnabled']) {
                        this.parent.undoRedoModule['disableRedo']();
                    }
                    this.parent.undoRedoModule['createUndoCollection']();
                    var record = {};
                    record['action'] = 'ColumnReorder';
                    record['fromIndex'] = ej2_base_1.extend([], [], [args['fromIndex']], true)[0];
                    record['toIndex'] = ej2_base_1.extend([], [], [args['toIndex']], true)[0];
                    record['toColumn'] = ej2_base_1.extend([], [], [this.parent.treeGrid.columns[args['toIndex']]['field']], true)[0];
                    record['fromColumn'] = ej2_base_1.extend([], [], [this.parent.treeGrid.columns[args['fromIndex']]['field']], true)[0];
                    this.parent.undoRedoModule['getUndoCollection'][this.parent.undoRedoModule['getUndoCollection'].length - 1] = record;
                }
            }
            if (ej2_base_1.getValue('requestType', args) === 'columnstate') {
                if (this.parent.undoRedoModule && !this.parent.undoRedoModule['isFromUndoRedo'] && this.parent['isUndoRedoItemPresent']('ColumnState')) {
                    Iif (this.parent.undoRedoModule['redoEnabled']) {
                        this.parent.undoRedoModule['disableRedo']();
                    }
                    this.parent.undoRedoModule['createUndoCollection']();
                    var record = { action: 'ColumnState' };
                    record['showhideColumns'] = ej2_base_1.extend([], [], args['columns'], true);
                    this.parent.undoRedoModule['getUndoCollection'][this.parent.undoRedoModule['getUndoCollection'].length - 1] = record;
                }
            }
            if (ej2_base_1.getValue('requestType', args) === 'sorting') {
                if (this.parent.undoRedoModule && this.parent['isUndoRedoItemPresent']('Sorting')) {
                    Iif (this.parent.undoRedoModule['currentAction'] && this.parent.undoRedoModule['currentAction']['sortColumns'].length > 1) {
                        this.parent.undoRedoModule['sortedColumnsLength']++;
                    }
                    if ((!this.parent.undoRedoModule['currentAction'] || (this.parent.undoRedoModule['sortedColumnsLength'] !== this.parent.undoRedoModule['currentAction']['sortColumns'].length)) && !this.parent.undoRedoModule['isFromUndoRedo']) {
                        Iif (this.parent.undoRedoModule['redoEnabled']) {
                            this.parent.undoRedoModule['disableRedo']();
                        }
                        this.parent.undoRedoModule['createUndoCollection']();
                        var record = { action: 'Sorting' };
                        record['sortColumns'] = [];
                        record['sortColumns'] = this.parent.undoRedoModule['previousSortedColumns'];
                        this.parent.undoRedoModule['getUndoCollection'][this.parent.undoRedoModule['getUndoCollection'].length - 1] = record;
                    }
                    this.parent.undoRedoModule['previousSortedColumns'] = this.parent.treeGrid.sortSettings.columns;
                }
                this.parent.notify('updateModel', {});
                ej2_base_1.deleteObject(updatedArgs, 'isFrozen');
            }
            else if (ej2_base_1.getValue('requestType', args) === 'filtering') {
                if (this.parent.undoRedoModule && !this.parent.undoRedoModule['isFromUndoRedo'] && this.parent['isUndoRedoItemPresent']('Filtering')) {
                    Iif (this.parent.undoRedoModule['redoEnabled']) {
                        this.parent.undoRedoModule['disableRedo']();
                    }
                    this.parent.undoRedoModule['createUndoCollection']();
                    var record = { action: 'Filtering' };
                    record['filteredColumns'] = ej2_base_1.extend([], [], args['columns'], true);
                    this.parent.undoRedoModule['getUndoCollection'][this.parent.undoRedoModule['getUndoCollection'].length - 1] = record;
                }
                this.parent.notify('updateModel', {});
                var focussedElement = this.parent.element.querySelector('.e-treegrid');
                focussedElement.focus();
            }
            else if (ej2_base_1.getValue('type', args) === 'save') {
                Eif (this.parent.editModule && this.parent.editModule.cellEditModule) {
                    var data = ej2_base_1.getValue('data', args);
                    Eif (!ej2_base_1.isNullOrUndefined(data) && !ej2_base_1.isNullOrUndefined(this.parent.getTaskByUniqueID(data.uniqueID))) {
                        this.parent.getTaskByUniqueID(data.uniqueID).taskData[this.parent.taskFields.duration] = data.taskData[this.parent.taskFields.duration];
                        if (!ej2_base_1.isNullOrUndefined(data.taskData[this.parent.taskFields.resourceInfo])) {
                            this.parent.getTaskByUniqueID(data.uniqueID).taskData[this.parent.taskFields.resourceInfo] = data.taskData[this.parent.taskFields.resourceInfo];
                        }
                    }
                    this.parent.editModule.cellEditModule.initiateCellEdit(args, this.currentEditRow);
                    this.parent.editModule.cellEditModule.isCellEdit = false;
                    this.currentEditRow = {};
                }
            }
            if (ej2_base_1.getValue('requestType', args) === 'filterAfterOpen') {
                this.parent.notify('actionComplete', args);
            }
            if (ej2_base_1.getValue('requestType', args) === 'searching') {
                if (this.parent.undoRedoModule && this.parent['isUndoRedoItemPresent']('Search')) {
                    if (!this.parent.undoRedoModule['isFromUndoRedo']) {
                        Iif (this.parent.undoRedoModule['redoEnabled']) {
                            this.parent.undoRedoModule['disableRedo']();
                        }
                        this.parent.undoRedoModule['createUndoCollection']();
                        var record = { 'action': 'Search' };
                        record['searchString'] = this.parent.undoRedoModule['searchString'];
                        this.parent.undoRedoModule['getUndoCollection'][this.parent.undoRedoModule['getUndoCollection'].length - 1] = record;
                    }
                    this.parent.undoRedoModule['searchString'] = this.parent.treeGrid.searchSettings.key;
                }
                this.parent.notify('actionComplete', args);
            }
            Iif (!ej2_base_1.isNullOrUndefined(this.parent.toolbarModule) && !ej2_base_1.isNullOrUndefined(ej2_base_1.getValue('batchChanges', args))) {
                this.parent.toolbarModule.refreshToolbarItems();
            }
            if (this.parent.isCancelled) {
                ej2_base_2.setValue('requestType', 'cancel', updatedArgs);
                ej2_base_2.setValue('action', 'CellEditing', updatedArgs);
                this.parent.isCancelled = false;
            }
            if (ej2_base_1.getValue('requestType', args) === 'refresh' && ej2_base_1.isNullOrUndefined(ej2_base_1.getValue('type', args)) && this.parent.addDeleteRecord) {
                if (this.parent.selectedRowIndex !== -1) {
                    Iif (!ej2_base_1.isNullOrUndefined(this.parent.selectionModule) &&
                        this.parent.selectionSettings &&
                        this.parent.selectionSettings.persistSelection &&
                        this.parent.editModule.isAdded) {
                        var selectedIndexes = this.parent.selectionModule.selectedRowIndexes;
                        if (selectedIndexes.length > 1 && this.parent.selectionSettings.persistSelection) {
                            for (var i = 0; i < selectedIndexes.length; i++) {
                                var records = this.parent.flatData[selectedIndexes[i].toString()];
                                this.parent.selectRows(records);
                            }
                        }
                    }
                    else {
                        this.parent.selectRow(this.parent.selectedRowIndex);
                        if (this.parent.selectedRowIndex > this.parent.currentViewData.length - 1) {
                            this.parent.selectedRowIndex = -1;
                        }
                    }
                }
                else {
                    Iif (!ej2_base_1.isNullOrUndefined(this.parent.selectionModule) && this.parent.selectionSettings &&
                        this.parent.selectionSettings.persistSelection
                        && this.parent.editModule && !this.parent.editModule.isAdded) {
                        var selectedRecords = this.parent.selectionModule.getSelectedRecords();
                        var _loop_1 = function (i) {
                            var selectedTaskId = selectedRecords[i][this_1.parent.taskFields.id];
                            var existIndeletedRecords = this_1.parent.editModule.deletedRecord.some(function (item) {
                                return item.ganttProperties.taskId === selectedTaskId;
                            });
                            if (existIndeletedRecords) {
                                selectedRecords.splice(i, 1);
                            }
                        };
                        var this_1 = this;
                        for (var i = selectedRecords.length - 1; i >= 0; i--) {
                            _loop_1(i);
                        }
                    }
                    var indexvalue_1 = 0;
                    var dataCollection = this.parent.enableVirtualization ? this.parent.flatData : this.parent.currentViewData;
                    dataCollection.map(function (data, index) {
                        if (!ej2_base_1.isNullOrUndefined(_this.parent.currentSelection)
                            && (data['ganttProperties'].taskId === _this.parent.currentSelection[_this.parent.taskFields.id])) {
                            indexvalue_1 = index;
                        }
                    });
                    this.addedRecord = true;
                    this.parent.selectRow((ej2_base_1.isNullOrUndefined(indexvalue_1) ? 0 : indexvalue_1));
                }
                Eif (!this.parent['isExpandPerformed']) {
                    this.parent.addDeleteRecord = false;
                }
                this.parent['isExpandPerformed'] = false;
            }
            if (this.parent.undoRedoModule) {
                this.parent.undoRedoModule['isFromUndoRedo'] = false;
            }
            this.parent.trigger('actionComplete', updatedArgs);
            if (this.parent.showOverAllocation && !this.parent.allowTaskbarOverlap) {
                for (var i = 0; i < this.parent.currentViewData.length; i++) {
                    Iif (this.parent.currentViewData[i].hasChildRecords && !this.parent.currentViewData[i].expanded) {
                        this.parent.chartRowsModule.updateDragDropRecords(this.parent.currentViewData[i]);
                    }
                }
                this.parent.ganttChartModule.renderRangeContainer(this.parent.currentViewData);
            }
            if (!ej2_base_1.isNullOrUndefined(this.parent.loadingIndicator) && this.parent.loadingIndicator.indicatorType === 'Shimmer') {
                this.parent.hideMaskRow();
            }
            else {
                this.parent.hideSpinner();
            }
        };
        GanttTreeGrid.prototype.updateKeyConfigSettings = function () {
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.delete;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.insert;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.upArrow;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.downArrow;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.ctrlHome;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.ctrlEnd;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.enter;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.tab;
            delete this.parent.treeGrid.grid.keyboardModule.keyConfigs.shiftTab;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.enter;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.upArrow;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.downArrow;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.ctrlShiftUpArrow;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.ctrlShiftDownArrow;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.ctrlUpArrow;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.ctrlDownArrow;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.tab;
            delete this.parent.treeGrid.keyboardModule.keyConfigs.shiftTab;
        };
        GanttTreeGrid.prototype.wireEvents = function () {
            var content = this.parent.treeGrid.element.querySelector('.e-content');
            Eif (content) {
                ej2_base_1.EventHandler.add(content, 'scroll', this.scrollHandler, this);
            }
            if (this.parent.isAdaptive) {
                ej2_base_1.EventHandler.add(this.parent.treeGridPane, 'click', this.treeGridClickHandler, this);
            }
        };
        GanttTreeGrid.prototype.unWireEvents = function () {
            var content = this.parent.treeGrid.element &&
                this.parent.treeGrid.element.querySelector('.e-content');
            Eif (content) {
                ej2_base_1.EventHandler.remove(content, 'scroll', this.scrollHandler);
            }
            if (this.parent.isAdaptive) {
                ej2_base_1.EventHandler.remove(this.parent.treeGridPane, 'click', this.treeGridClickHandler);
            }
        };
        GanttTreeGrid.prototype.scrollHandler = function (e) {
            var content = this.parent.treeGrid.element.querySelector('.e-content');
            if (content.scrollTop !== this.previousScroll.top) {
                this.parent.notify('grid-scroll', { top: content.scrollTop });
            }
            this.previousScroll.top = content.scrollTop;
            if (this.parent.contextMenuModule && this.parent.contextMenuModule.isOpen) {
                this.parent.contextMenuModule.contextMenu.close();
            }
        };
        GanttTreeGrid.prototype.validateGanttColumns = function () {
            var ganttObj = this.parent;
            var length = ganttObj.columns.length;
            var tasks = this.parent.taskFields;
            this.parent.columnMapping = {};
            this.parent.columnByField = {};
            this.parent.customColumns = [];
            var tasksMapping = ['id', 'name', 'startDate', 'endDate', 'duration', 'dependency',
                'progress', 'baselineStartDate', 'baselineEndDate', 'resourceInfo', 'notes', 'work', 'manual', 'type', 'milestone', 'segments'];
            var _loop_2 = function (i) {
                var column = {};
                Iif (typeof ganttObj.columns[i] === 'string') {
                    column.field = ganttObj.columns[i];
                }
                else {
                    column = ganttObj.columns[i];
                }
                var columnName = [];
                Eif (tasksMapping.length > 0) {
                    columnName = tasksMapping.filter(function (name) {
                        return column.field === tasks[name];
                    });
                }
                if (columnName.length === 0) {
                    if (column.field === this_2.parent.resourceFields.group) {
                        return "continue";
                    }
                    this_2.parent.customColumns.push(column.field);
                    column.headerText = column.headerText ? column.headerText : column.field;
                    column.width = column.width ? column.width : 150;
                    column.editType = column.editType ? column.editType : 'stringedit';
                    column.type = column.type ? column.type : 'string';
                    this_2.bindTreeGridColumnProperties(column, true);
                    return "continue";
                }
                else {
                    var index = tasksMapping.indexOf(columnName[0]);
                    tasksMapping.splice(index, 1);
                    this_2.createTreeGridColumn(column, true);
                    this_2.parent.columnMapping[columnName[0]] = column.field;
                }
            };
            var this_2 = this;
            for (var i = 0; i < length; i++) {
                _loop_2(i);
            }
            for (var j = 0; j < tasksMapping.length; j++) {
                var column = {};
                if (!ej2_base_1.isNullOrUndefined(tasks[tasksMapping[j]])) {
                    column.field = tasks[tasksMapping[j]];
                    this.createTreeGridColumn(column, length === 0);
                    this.parent.columnMapping[tasksMapping[j]] = column.field;
                }
            }
            if (this.parent.viewType !== 'ProjectView') {
                var column = {};
                this.composeUniqueIDColumn(column);
                this.createTreeGridColumn(column, true);
            }
        };
        GanttTreeGrid.prototype.createTreeGridColumn = function (column, isDefined) {
            var _this = this;
            var taskSettings = this.parent.taskFields;
            var previousColumn = this.parent.previousGanttColumns.filter(function (prevcolumn) {
                return column.field === prevcolumn.field;
            })[0];
            column.disableHtmlEncode = !ej2_base_1.isNullOrUndefined(column.disableHtmlEncode) ? column.disableHtmlEncode : this.parent.disableHtmlEncode;
            if (taskSettings.id !== column.field) {
                column.clipMode = column.clipMode ? column.clipMode : 'EllipsisWithTooltip';
            }
            if (taskSettings.id === column.field) {
                this.composeIDColumn(column);
            }
            else if (taskSettings.name === column.field) {
                Iif (this.parent.isLocaleChanged && previousColumn) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('name');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('name');
                }
                column.width = column.width ? column.width : 150;
                column.editType = column.editType ? column.editType : 'stringedit';
                column.type = column.type ? column.type : 'string';
            }
            else if (taskSettings.startDate === column.field) {
                Iif (this.parent.isLocaleChanged && previousColumn) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('startDate');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('startDate');
                }
                column.editType = column.editType ? column.editType :
                    this.parent.getDateFormat().toLowerCase().indexOf('hh') !== -1 ? 'datetimepickeredit' : 'datepickeredit';
                column.format = column.format ? column.format : { type: 'date', format: this.parent.getDateFormat() };
                column.width = column.width ? column.width : 150;
                if (column.edit && column.edit.params) {
                    column.edit.params['renderDayCell'] = this.parent.renderWorkingDayCell.bind(this.parent);
                }
                else {
                    if (column.edit) {
                        column.edit.params = { renderDayCell: this.parent.renderWorkingDayCell.bind(this.parent) };
                    }
                    else {
                        column.edit = { params: { renderDayCell: this.parent.renderWorkingDayCell.bind(this.parent) } };
                    }
                }
            }
            else if (taskSettings.endDate === column.field) {
                Iif (this.parent.isLocaleChanged && previousColumn) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('endDate');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('endDate');
                }
                column.format = column.format ? column.format : { type: 'date', format: this.parent.getDateFormat() };
                column.editType = column.editType ? column.editType :
                    this.parent.getDateFormat().toLowerCase().indexOf('hh') !== -1 ? 'datetimepickeredit' : 'datepickeredit';
                column.width = column.width ? column.width : 150;
                if (column.edit && column.edit.params) {
                    column.edit.params['renderDayCell'] = this.parent.renderWorkingDayCell.bind(this.parent);
                }
                else {
                    Iif (column.edit) {
                        column.edit.params = { renderDayCell: this.parent.renderWorkingDayCell.bind(this.parent) };
                    }
                    else {
                        column.edit = { params: { renderDayCell: this.parent.renderWorkingDayCell.bind(this.parent) } };
                    }
                }
            }
            else if (taskSettings.duration === column.field) {
                column.width = column.width ? column.width : 150;
                Iif (this.parent.isLocaleChanged && previousColumn) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('duration');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('duration');
                }
                column.valueAccessor = column.valueAccessor ?
                    column.valueAccessor : !ej2_base_1.isNullOrUndefined(column.edit) && !ej2_base_1.isNullOrUndefined(column.edit.read) ? null :
                    this.durationValueAccessor.bind(this);
                column.editType = column.editType ? column.editType : 'stringedit';
                column.type = column.type ? column.type : 'string';
            }
            else if (taskSettings.progress === column.field) {
                this.composeProgressColumn(column);
            }
            else if (taskSettings.dependency === column.field) {
                Iif (this.parent.isLocaleChanged && previousColumn) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('dependency');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('dependency');
                }
                column.width = column.width ? column.width : 150;
                column.editType = column.editType ? column.editType : 'stringedit';
                column.type = 'string';
                column.allowFiltering = column.allowFiltering === false ? false : true;
                column.valueAccessor = column.valueAccessor ? column.valueAccessor : this.dependencyValueAccessor.bind(this);
                if (ej2_base_1.isNullOrUndefined(column.filter) && this.parent.locale !== 'en-US') {
                    column.filter = {
                        'ui': {
                            create: function (args) {
                                var flValInput = ej2_base_1.createElement('input', { className: 'flm-input' });
                                args.target.appendChild(flValInput);
                                _this.dropInstance = new ej2_dropdowns_1.AutoComplete({
                                    dataSource: _this.changeLocale(_this.parent.treeGrid.grid.dataSource),
                                    fields: { text: _this.parent.taskFields.dependency, value: _this.parent.taskFields.dependency },
                                    placeholder: _this.parent.localeObj.getConstant('enterValue'),
                                    popupHeight: '200px'
                                });
                                _this.dropInstance.appendTo(flValInput);
                            },
                            write: function (args) {
                                _this.dropInstance.value = args.filteredValue;
                            },
                            read: function (args) {
                                args.fltrObj.filterByColumn(args.column.field, args.operator, _this.changeDelocale((_this.dropInstance.value)));
                            }
                        }
                    };
                }
            }
            else if (taskSettings.resourceInfo === column.field) {
                this.composeResourceColumn(column);
            }
            else if (taskSettings.notes === column.field) {
                Iif (previousColumn && this.parent.isLocaleChanged) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('notes');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('notes');
                }
                column.width = column.width ? column.width : 150;
                column.editType = column.editType ? column.editType : 'stringedit';
                Eif (!this.parent.showInlineNotes) {
                    if (!column.template) {
                        column.template = '<div class="e-ganttnotes-info">' +
                            '<span class="e-icons e-notes-info"></span></div>';
                    }
                }
            }
            else if (taskSettings.baselineStartDate === column.field ||
                taskSettings.baselineEndDate === column.field) {
                var colName = (taskSettings.baselineEndDate === column.field) ? 'baselineEndDate' :
                    'baselineStartDate';
                column.width = column.width ? column.width : 150;
                Iif (this.parent.isLocaleChanged && previousColumn) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant(colName);
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant(colName);
                }
                column.format = column.format ? column.format : { type: 'date', format: this.parent.getDateFormat() };
                column.editType = column.editType ? column.editType :
                    this.parent.getDateFormat().toLowerCase().indexOf('hh') !== -1 ? 'datetimepickeredit' : 'datepickeredit';
            }
            else if (taskSettings.work === column.field) {
                Iif (previousColumn && this.parent.isLocaleChanged) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('work');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('work');
                }
                column.width = column.width ? column.width : 150;
                column.valueAccessor = column.valueAccessor ? column.valueAccessor : this.workValueAccessor.bind(this);
                column.editType = column.editType ? column.editType : 'numericedit';
            }
            else if (taskSettings.type === column.field) {
                Iif (previousColumn && this.parent.isLocaleChanged) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('taskType');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('taskType');
                }
                column.width = column.width ? column.width : 150;
                column.editType = 'dropdownedit';
                column.valueAccessor = column.valueAccessor ? column.valueAccessor : this.taskTypeValueAccessor.bind(this);
            }
            else if (taskSettings.manual === column.field && this.parent.taskMode === 'Custom') {
                Iif (previousColumn && this.parent.isLocaleChanged) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('taskMode');
                }
                else {
                    column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('taskMode');
                }
                column.width = column.width ? column.width : 120;
                column.editType = column.editType ? column.editType : 'dropdownedit';
                column.valueAccessor = column.valueAccessor ? column.valueAccessor : this.modeValueAccessor.bind(this);
                column.edit = {
                    params: {
                        query: new ej2_data_1.Query(),
                        dataSource: [
                            { id: 1, text: this.parent.localeObj.getConstant('manual'), value: true },
                            { id: 2, text: this.parent.localeObj.getConstant('auto'), value: false }
                        ],
                        fields: { text: 'text', value: 'value' }
                    }
                };
            }
            this.bindTreeGridColumnProperties(column, isDefined);
        };
        GanttTreeGrid.prototype.changeLocale = function (data) {
            var _this = this;
            var filter = [];
            var flatdatas = data.map(function (task) { return task.ganttProperties.predecessorsName; });
            flatdatas.map(function (predecessorsName) {
                if (!ej2_base_1.isNullOrUndefined(predecessorsName)) {
                    var value_1 = '';
                    var splitString_1 = predecessorsName.split(',');
                    splitString_1.map(function (splitvalue, index) {
                        if (splitvalue.includes('FS')) {
                            value_1 += splitvalue.replace('FS', _this.parent.localeObj.getConstant('FS'));
                            value_1 += (splitString_1.length !== index + 1) ? ',' : '';
                        }
                        else if (splitvalue.includes('FF')) {
                            value_1 += splitvalue.replace('FF', _this.parent.localeObj.getConstant('FF'));
                            value_1 += (splitString_1.length !== index + 1) ? ',' : '';
                        }
                        else if (splitvalue.includes('SS')) {
                            value_1 += splitvalue.replace('SS', _this.parent.localeObj.getConstant('SS'));
                            value_1 += (splitString_1.length !== index + 1) ? ',' : '';
                        }
                        else Eif (splitvalue.includes('SF')) {
                            value_1 += splitvalue.replace('SF', _this.parent.localeObj.getConstant('SF'));
                            value_1 += (splitString_1.length !== index + 1) ? ',' : '';
                        }
                    });
                    filter.push(value_1);
                }
            });
            return filter;
        };
        GanttTreeGrid.prototype.changeDelocale = function (dependency) {
            var FF = this.parent.localeObj.getConstant('FF');
            var FS = this.parent.localeObj.getConstant('FS');
            var SS = this.parent.localeObj.getConstant('SS');
            var SF = this.parent.localeObj.getConstant('SF');
            if (!ej2_base_1.isNullOrUndefined(dependency)) {
                var splitString_2 = dependency.split(',');
                var value_2 = '';
                splitString_2.map(function (splitvalue, index) {
                    if (splitvalue.includes(FF)) {
                        value_2 += splitvalue.replace(FF, 'FF');
                        value_2 += (splitString_2.length !== index + 1) ? ',' : '';
                    }
                    else if (splitvalue.includes(FS)) {
                        value_2 += splitvalue.replace(FS, 'FS');
                        value_2 += (splitString_2.length !== index + 1) ? ',' : '';
                    }
                    else if (splitvalue.includes(SS)) {
                        value_2 += splitvalue.replace(SS, 'SS');
                        value_2 += (splitString_2.length !== index + 1) ? ',' : '';
                    }
                    else if (splitvalue.includes(SF)) {
                        value_2 += splitvalue.replace(SF, 'SF');
                        value_2 += (splitString_2.length !== index + 1) ? ',' : '';
                    }
                    else {
                        value_2 += splitvalue;
                        value_2 += (splitString_2.length !== index + 1) ? ',' : '';
                    }
                });
                return value_2;
            }
            return null;
        };
        GanttTreeGrid.prototype.composeResourceColumn = function (column) {
            var previousColumn = this.parent.previousGanttColumns.filter(function (prevcolumn) {
                return column.field === prevcolumn.field;
            })[0];
            Iif (previousColumn && this.parent.isLocaleChanged) {
                column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('resourceName');
            }
            else {
                column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('resourceName');
            }
            column.width = column.width ? column.width : 150;
            column.type = 'string';
            column.valueAccessor = column.valueAccessor ? column.valueAccessor : this.resourceValueAccessor.bind(this);
            column.allowFiltering = column.allowFiltering === false ? false : true;
        };
        GanttTreeGrid.prototype.getResourceIds = function (data) {
            var value = ej2_base_1.getValue(this.parent.taskFields.resourceInfo, data.taskData);
            var id = [];
            if (!ej2_base_1.isNullOrUndefined(value)) {
                for (var i = 0; i < value.length; i++) {
                    id.push(typeof value[i] === 'object' ? value[i][this.parent.resourceFields.id] : value[i]);
                }
                return id;
            }
            else {
                return value;
            }
        };
        GanttTreeGrid.prototype.composeIDColumn = function (column) {
            var isProjectView = this.parent.viewType === 'ProjectView';
            var lengthDataSource = this.parent.dataSource ? this.parent.dataSource['length'] : 0;
            var taskIDName;
            column.isPrimaryKey = isProjectView ? true : false;
            if (this.parent.isLocaleChanged) {
                var previousColumn = this.parent.previousGanttColumns.filter(function (prevcolumn) {
                    return column.field === prevcolumn.field;
                })[0];
                Iif (previousColumn) {
                    column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('id');
                }
            }
            else {
                column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('id');
            }
            column.width = column.width ? column.width : 100;
            for (var i = 0; i < lengthDataSource; i++) {
                if (!ej2_base_1.isNullOrUndefined(this.parent.dataSource[i][this.parent.taskFields.id])) {
                    taskIDName = this.parent.dataSource[i][this.parent.taskFields.id];
                    break;
                }
            }
            if (typeof (taskIDName) === 'string' || ej2_base_1.isNullOrUndefined(taskIDName)) {
                if (this.parent.viewType === 'ResourceView') {
                    column.allowEditing = column.allowEditing ? column.allowEditing : false;
                }
                else {
                    column.allowEditing = column.allowEditing ? column.allowEditing : true;
                }
                column.editType = column.editType ? column.editType : 'stringedit';
            }
            else {
                column.allowEditing = column.allowEditing ? column.allowEditing : false;
                column.editType = column.editType ? column.editType : 'numericedit';
            }
            column.valueAccessor = isProjectView ? null : this.idValueAccessor.bind(this);
        };
        GanttTreeGrid.prototype.composeUniqueIDColumn = function (column) {
            column.field = 'rowUniqueID';
            column.isPrimaryKey = true;
            column.headerText = 'UniqueID';
            column.allowEditing = false;
            column.visible = false;
        };
        GanttTreeGrid.prototype.composeProgressColumn = function (column) {
            var previousColumn = this.parent.previousGanttColumns.filter(function (prevcolumn) {
                return column.field === prevcolumn.field;
            })[0];
            Iif (this.parent.isLocaleChanged && previousColumn) {
                column.headerText = previousColumn.headerText ? previousColumn.headerText : this.parent.localeObj.getConstant('progress');
            }
            else {
                column.headerText = column.headerText ? column.headerText : this.parent.localeObj.getConstant('progress');
            }
            column.width = column.width ? column.width : 150;
            column.editType = column.editType ? column.editType : 'numericedit';
        };
        GanttTreeGrid.prototype.bindTreeGridColumnProperties = function (newGanttColumn, isDefined) {
            var treeGridColumn = {};
            var ganttColumn = {};
            for (var _i = 0, _a = Object.keys(newGanttColumn); _i < _a.length; _i++) {
                var prop = _a[_i];
                treeGridColumn[prop] = ganttColumn[prop] = newGanttColumn[prop];
            }
            this.parent.columnByField[ganttColumn.field] = ganttColumn;
            this.parent.ganttColumns.push(new column_1.Column(ganttColumn));
            if (isDefined) {
                this.treeGridColumns.push(treeGridColumn);
            }
        };
        GanttTreeGrid.prototype.durationValueAccessor = function (field, data, column) {
            if (!ej2_base_1.isNullOrUndefined(data) && !ej2_base_1.isNullOrUndefined(data.ganttProperties)) {
                var ganttProp = data.ganttProperties;
                return this.parent.dataOperation.getDurationString(ganttProp.duration, ganttProp.durationUnit);
            }
            else Iif (this.parent.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                return this.parent.dataOperation.getDurationString(parseInt(data[this.parent.taskFields.duration], 10), this.parent.durationUnit);
            }
            return '';
        };
        GanttTreeGrid.prototype.dependencyValueAccessor = function (field, data, column) {
            var _this = this;
            if (data && data.ganttProperties && !ej2_base_1.isNullOrUndefined(data.ganttProperties.predecessorsName)) {
                var value_3 = '';
                var predecessorsName = data.ganttProperties.predecessorsName;
                var splitString_3 = predecessorsName.split(',');
                splitString_3.map(function (splitvalue, index) {
                    if (splitvalue.includes('FS')) {
                        value_3 += splitvalue.replace('FS', _this.parent.localeObj.getConstant('FS'));
                        value_3 += (splitString_3.length !== index + 1) ? ',' : '';
                    }
                    else if (splitvalue.includes('FF')) {
                        value_3 += splitvalue.replace('FF', _this.parent.localeObj.getConstant('FF'));
                        value_3 += (splitString_3.length !== index + 1) ? ',' : '';
                    }
                    else if (splitvalue.includes('SS')) {
                        value_3 += splitvalue.replace('SS', _this.parent.localeObj.getConstant('SS'));
                        value_3 += (splitString_3.length !== index + 1) ? ',' : '';
                    }
                    else if (splitvalue.includes('SF')) {
                        value_3 += splitvalue.replace('SF', _this.parent.localeObj.getConstant('SF'));
                        value_3 += (splitString_3.length !== index + 1) ? ',' : '';
                    }
                });
                return value_3;
            }
            return '';
        };
        GanttTreeGrid.prototype.resourceValueAccessor = function (field, data, column) {
            var ganttProp = data.ganttProperties;
            Eif (!ej2_base_1.isNullOrUndefined(ganttProp)) {
                return ganttProp.resourceNames;
            }
            return '';
        };
        GanttTreeGrid.prototype.workValueAccessor = function (field, data, column) {
            var ganttProp = data.ganttProperties;
            Eif (!ej2_base_1.isNullOrUndefined(ganttProp)) {
                return this.parent.dataOperation.getWorkString(ganttProp.work, ganttProp.workUnit);
            }
            return '';
        };
        GanttTreeGrid.prototype.taskTypeValueAccessor = function (field, data, column) {
            var ganttProp = data.ganttProperties;
            Eif (!ej2_base_1.isNullOrUndefined(ganttProp)) {
                return ganttProp.taskType;
            }
            return '';
        };
        GanttTreeGrid.prototype.modeValueAccessor = function (field, data, column) {
            if (data[field]) {
                return 'Manual';
            }
            else {
                return 'Auto';
            }
        };
        GanttTreeGrid.prototype.idValueAccessor = function (field, data, column) {
            return data.level === 0 ? 'R-' + data.ganttProperties.taskId : 'T-' + data.ganttProperties.taskId;
        };
        GanttTreeGrid.prototype.updateScrollTop = function (args) {
            var newScrollTop = ej2_base_1.getValue('top', args);
            this.treeGridElement.querySelector('.e-content').scrollTop = newScrollTop;
            this.previousScroll.top = this.treeGridElement.querySelector('.e-content').scrollTop;
        };
        GanttTreeGrid.prototype.treeGridClickHandler = function (e) {
            this.parent.notify('treeGridClick', e);
        };
        GanttTreeGrid.prototype.removeEventListener = function () {
            this.parent.off('renderPanels', this.createContainer);
            this.parent.off('chartScroll', this.updateScrollTop);
            this.parent.off('destroy', this.destroy);
            this.parent.treeGrid.off('reactTemplateRender', this.renderReactTemplate);
        };
        GanttTreeGrid.prototype.destroy = function () {
            this.removeEventListener();
            this.unWireEvents();
            Eif (this.parent.treeGrid.element) {
                this.parent.treeGrid.destroy();
            }
        };
        return GanttTreeGrid;
    }());
    exports.GanttTreeGrid = GanttTreeGrid;
});