all files / common/popups/ toolbar.js

71.35% Statements 630/883
64.6% Branches 427/661
69.12% Functions 47/68
71.32% Lines 629/882
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 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806   39× 39× 39× 39× 39× 39×   1809×   39× 39× 39×     39×       39×     39×         39×   39×                   39× 39× 39× 39× 39×       39×           39×   39× 39×     39×         18× 18× 18×                 184× 39× 39× 184× 184×   10×       10×   10×       10×   10×       10×   10×       10×   10×       10×   10×         10×     14× 14×           14×     14× 14×         14×   10×         10×   35×       35×   11×       11×   11×       11×   11×       11×                       15×       15×     15×             39×       39× 39× 39×                                                                                                                                                                     25×       25× 25×     25× 25×                                                                     39×     39×       39× 39×                                                                   39× 39×                                                                                                                                                                                                                                                                                                                                                                                                                                                 14× 14× 14× 14× 14× 14× 98× 98×         14× 14× 14×         14× 14×     14×       14×       14×       14× 14×       14×                     14× 14×     39× 39× 14×   39× 35× 35×                                                                     35×           50×     35× 35×   39× 11× 11×                                                                                                   11×           20×     11× 11×   39× 11× 11×                                                                                         11×           18×     11× 11×   39×                                                   39×       39× 39× 39× 10× 10× 10×                     10× 10×   39×             39× 39× 185× 185× 104×   81× 71× 71× 71×             104× 104×                                           95×                                       463×       50× 50× 39× 39×     11× 11×     20× 18× 18×   18× 18×   18× 18×   18× 18×   18×     14×     12×                         18× 17× 17×   17× 17×   17× 17×   17× 17×   17×     13×     12×                                       98× 98× 98× 98×               98× 98× 17×   81×         81× 81×                           11×       11×                                                                                                                                                         39×     39×   14× 14× 364× 364× 350×     14×                                                                                                                                                                                                                                                                                                                                                                                                                         78× 39×   39×   78× 78× 78× 78×   78× 78× 78× 39× 39×   78× 78× 78×       78× 78× 78× 14× 14×   78× 78× 78×       78× 78× 78× 35× 35×   78× 78× 78× 11× 11×   78× 78× 78× 11× 11×   78× 78× 78×       78× 78× 78× 10× 10×   78× 39× 39×   78× 78× 39×     97× 97× 97× 97×          
define(["require", "exports", "@syncfusion/ej2-navigations", "@syncfusion/ej2-base", "../../common/base/constant", "@syncfusion/ej2-popups", "@syncfusion/ej2-dropdowns", "../../common/base/css-constant", "../../pivotview/base/pivotview", "@syncfusion/ej2-data", "@syncfusion/ej2-buttons"], function (require, exports, ej2_navigations_1, ej2_base_1, events, ej2_popups_1, ej2_dropdowns_1, cls, pivotview_1, ej2_data_1, ej2_buttons_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Toolbar = (function () {
        function Toolbar(parent) {
            this.isMultiAxisChange = false;
            this.isReportChange = false;
            this.currentReport = '';
            this.parent = parent;
            this.parent.toolbarModule = this;
            this.addEventListener();
        }
        Toolbar.prototype.getModuleName = function () {
            return 'toolbar';
        };
        Toolbar.prototype.createToolbar = function () {
            this.parent.isModified = false;
            this.renderDialog();
            Iif (ej2_base_1.select('#' + this.parent.element.id + 'pivot-toolbar', this.parent.element) !== null) {
                ej2_base_1.remove(ej2_base_1.select('#' + this.parent.element.id + 'pivot-toolbar', this.parent.element));
            }
            var element = ej2_base_1.createElement('div', {
                id: this.parent.element.id + 'pivot-toolbar',
                className: cls.GRID_TOOLBAR
            });
            Iif (this.parent.showFieldList && ej2_base_1.select('#' + this.parent.element.id + '_PivotFieldList', this.parent.element)) {
                this.parent.element.insertBefore(element, ej2_base_1.select('#' + this.parent.element.id + '_PivotFieldList', this.parent.element));
            }
            else Iif (this.parent.showGroupingBar &&
                ej2_base_1.select('#' + this.parent.element.id + ' .' + 'e-pivot-grouping-bar', this.parent.element)) {
                this.parent.element.insertBefore(element, ej2_base_1.select('#' + this.parent.element.id + ' .' + 'e-pivot-grouping-bar', this.parent.element));
            }
            else {
                this.parent.element.insertBefore(element, ej2_base_1.select('#' + this.parent.element.id + '_grid', this.parent.element));
            }
            this.toolbar = new ej2_navigations_1.Toolbar({
                created: this.create.bind(this),
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                items: this.getItems(),
                allowKeyboard: false,
                cssClass: this.parent.cssClass,
                width: !this.parent.gridSettings.allowAutoResizing ? (this.parent.grid ? (this.parent.getGridWidthAsNumber() - 2) : (this.parent.getWidthAsNumber() - 2)) : 'auto'
            });
            this.toolbar.isStringTemplate = true;
            var viewStr = 'viewContainerRef';
            var registerTemp = 'registeredTemplate';
            var registeredTemplate = {};
            Iif ((this.parent)[viewStr]) {
                ej2_base_1.setValue(registerTemp, registeredTemplate, this.toolbar);
                (this.toolbar)[viewStr] = (this.parent)[viewStr];
            }
            Iif (this.parent.toolbarTemplate && typeof (this.parent.toolbarTemplate) === 'string') {
                this.toolbar.appendTo(this.parent.toolbarTemplate);
                this.parent.element.replaceChild(this.toolbar.element, this.parent.element.querySelector('.' + cls.GRID_TOOLBAR));
                this.toolbar.element.classList.add(cls.GRID_TOOLBAR);
            }
            else {
                this.toolbar.appendTo(element);
            }
            this.toolbar.width = this.parent.grid ? this.parent.getGridWidthAsNumber() : this.parent.getWidthAsNumber();
            Iif (this.parent.chart) {
                this.parent.chart.setProperties({ width: this.parent.grid ? this.parent.getGridWidthAsNumber().toString() : this.parent.getWidthAsNumber().toString() }, true);
            }
            Iif (this.parent.showGroupingBar && this.parent.groupingBarModule &&
                this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS)) {
                this.parent.groupingBarModule.refreshUI();
            }
        };
        Toolbar.prototype.fetchReports = function () {
            var reports = { reportName: [] };
            this.parent.trigger(events.fetchReport, reports);
            return reports;
        };
        Toolbar.prototype.fetchReportsArgs = function () {
            var callbackPromise = new ej2_data_1.Deferred();
            var reports = { reportName: [] };
            this.parent.trigger(events.fetchReport, reports, function (observedArgs) {
                callbackPromise.resolve(observedArgs);
            });
            return callbackPromise;
        };
        Toolbar.prototype.getItems = function () {
            var toolbar = this.parent.toolbar.filter(function (v, i, a) { return a.indexOf(v) === i; });
            var items = [];
            for (var _i = 0, toolbar_1 = toolbar; _i < toolbar_1.length; _i++) {
                var item = toolbar_1[_i];
                switch (item) {
                    case 'New':
                        items.push({
                            prefixIcon: cls.GRID_NEW + ' ' + cls.ICON, tooltipText: this.parent.localeObj.getConstant('new'),
                            click: this.actionClick.bind(this), id: this.parent.element.id + 'new'
                        });
                        break;
                    case 'Save':
                        items.push({
                            prefixIcon: cls.GRID_SAVE + ' ' + cls.ICON, tooltipText: this.parent.localeObj.getConstant('save'),
                            click: this.actionClick.bind(this), id: this.parent.element.id + 'save'
                        });
                        break;
                    case 'SaveAs':
                        items.push({
                            prefixIcon: cls.GRID_SAVEAS + ' ' + cls.ICON, tooltipText: this.parent.localeObj.getConstant('saveAs'),
                            click: this.actionClick.bind(this), id: this.parent.element.id + 'saveas'
                        });
                        break;
                    case 'Rename':
                        items.push({
                            prefixIcon: cls.GRID_RENAME + ' ' + cls.ICON, tooltipText: this.parent.localeObj.getConstant('rename'),
                            click: this.actionClick.bind(this), id: this.parent.element.id + 'rename'
                        });
                        break;
                    case 'Remove':
                        items.push({
                            prefixIcon: cls.GRID_REMOVE + ' ' + cls.ICON, tooltipText: this.parent.localeObj.getConstant('deleteReport'),
                            click: this.actionClick.bind(this), id: this.parent.element.id + 'remove'
                        });
                        break;
                    case 'Load':
                        items.push({
                            template: '<div><input class=' + cls.GRID_LOAD + ' id=' + this.parent.element.id + '_reportlist></input></div>',
                            click: this.actionClick.bind(this),
                            id: this.parent.element.id + 'load'
                        });
                        break;
                    case 'Grid':
                        {
                            var toDisable = this.parent.displayOption.view === 'Chart';
                            items.push({
                                prefixIcon: cls.TOOLBAR_GRID + ' ' + cls.ICON, tooltipText: this.parent.localeObj.getConstant('grid'),
                                id: this.parent.element.id + 'grid', cssClass: (toDisable ? cls.MENU_DISABLE : '') + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                                click: this.menuItemClick.bind(this)
                            });
                        }
                        break;
                    case 'Chart':
                        {
                            var validTypes = (this.parent.displayOption.view === 'Table');
                            items.push({
                                template: '<ul id="' + this.parent.element.id + 'chart_menu"></ul>',
                                id: this.parent.element.id + 'chartmenu', cssClass: (validTypes ? cls.MENU_DISABLE : '') + (this.parent.cssClass ? (' ' + this.parent.cssClass) : '')
                            });
                        }
                        break;
                    case 'MDX':
                        if (this.parent.dataType === 'olap') {
                            items.push({
                                prefixIcon: cls.GRID_MDX + ' ' + cls.ICON, id: this.parent.element.id + 'mdxQuery',
                                click: this.actionClick.bind(this), tooltipText: this.parent.localeObj.getConstant('mdxQuery')
                            });
                        }
                        break;
                    case 'Export':
                        items.push({
                            template: '<ul id="' + this.parent.element.id + 'export_menu"></ul>',
                            id: this.parent.element.id + 'exportmenu'
                        });
                        break;
                    case 'SubTotal':
                        items.push({
                            template: '<ul id="' + this.parent.element.id + 'subtotal_menu"></ul>',
                            id: this.parent.element.id + 'subtotalmenu'
                        });
                        break;
                    case 'GrandTotal':
                        items.push({
                            template: '<ul id="' + this.parent.element.id + 'grandtotal_menu"></ul>',
                            id: this.parent.element.id + 'grandtotalmenu'
                        });
                        break;
                    case 'ConditionalFormatting':
                        items.push({
                            prefixIcon: cls.GRID_FORMATTING + ' ' + cls.ICON, id: this.parent.element.id + 'formatting',
                            click: this.actionClick.bind(this), tooltipText: this.parent.localeObj.getConstant('toolbarFormatting')
                        });
                        break;
                    case 'NumberFormatting':
                        items.push({
                            prefixIcon: cls.FORMATTING_TOOLBAR + ' ' + cls.ICON, id: this.parent.element.id + 'numberFormatting',
                            click: this.actionClick.bind(this), tooltipText: this.parent.localeObj.getConstant('numberFormat')
                        });
                        break;
                    case 'Formatting':
                        items.push({
                            template: '<ul id="' + this.parent.element.id + 'formatting_menu"></ul>',
                            id: this.parent.element.id + 'formattingmenu'
                        });
                        break;
                    case 'FieldList':
                        items.push({
                            prefixIcon: cls.TOOLBAR_FIELDLIST + ' ' + cls.ICON, tooltipText: this.parent.localeObj.getConstant('fieldList'),
                            click: this.actionClick.bind(this), align: 'Right', id: this.parent.element.id + 'fieldlist'
                        });
                        Iif (this.parent.element.querySelector('.e-toggle-field-list')) {
                            this.parent.element.querySelector('.e-toggle-field-list').style.display = 'none';
                        }
                        break;
                    default:
                        if (typeof (item) === 'object') {
                            items.push(item);
                        }
                }
            }
            Iif (this.parent.showFieldList && toolbar.indexOf('FieldList') === -1 && ej2_base_1.select('#' + this.parent.element.id + '_PivotFieldList', this.parent.element) &&
                ej2_base_1.select('#' + this.parent.element.id + '_PivotFieldList', this.parent.element).style.display === 'none') {
                ej2_base_1.select('#' + this.parent.element.id + '_PivotFieldList', this.parent.element).style.display = 'block';
            }
            var toolbarArgs = { customToolbar: items };
            this.parent.trigger(events.toolbarRender, toolbarArgs);
            return items;
        };
        Toolbar.prototype.reportChange = function (args) {
            this.parent.actionObj.actionName = events.reportChange;
            this.isReportChange = true;
            if (this.parent.actionBeginMethod()) {
                args.cancel = true;
                return;
            }
            try {
                this.dropArgs = args;
                if (this.parent.isModified && this.currentReport !== '') {
                    this.createConfirmDialog(this.parent.localeObj.getConstant('alert'), this.parent.localeObj.getConstant('newReportConfirm'));
                }
                else {
                    this.reportLoad(args);
                }
            }
            catch (execption) {
                this.parent.actionFailureMethod(execption);
            }
        };
        Toolbar.prototype.reportLoad = function (args) {
            var _this_1 = this;
            if (this.action !== 'Save' && this.action !== 'Rename' && this.action !== 'New') {
                var loadArgs = {
                    reportName: args.itemData.value
                };
                var actionInfo = {
                    reportName: args.itemData.value
                };
                this.parent.actionObj.actionInfo = actionInfo;
                this.parent.trigger(events.loadReport, loadArgs, function (observedArgs) {
                    _this_1.currentReport = observedArgs.reportName;
                    _this_1.parent.isModified = false;
                });
            }
        };
        Toolbar.prototype.saveReport = function (args) {
            if (this.currentReport && this.currentReport !== '' && args.item.id === (this.parent.element.id + 'save')) {
                var saveArgs = {
                    report: this.getCurrentReport(),
                    reportName: this.currentReport
                };
                this.parent.actionObj.actionName = this.parent.getActionCompleteName();
                var actionInfo = {
                    reportName: this.currentReport
                };
                this.parent.actionObj.actionInfo = actionInfo;
                this.parent.trigger(events.saveReport, saveArgs);
                Eif (this.parent.actionObj.actionName) {
                    this.parent.actionCompleteMethod();
                }
                this.parent.isModified = false;
            }
            else Iif (this.currentReport === '' && (args.item.id === (this.parent.element.id + 'save') || args.item.id === (this.parent.element.id + 'saveas'))) {
                this.parent.pivotCommon.errorDialog.createErrorDialog(this.parent.localeObj.getConstant('error'), this.parent.localeObj.getConstant('emptyReport'));
                return;
            }
            else {
                this.dialogShow(args, 'saveAs');
            }
        };
        Toolbar.prototype.mdxQueryDialog = function () {
            if (!ej2_base_1.select('#' + this.parent.element.id + 'mdx-dialog', document)) {
                this.renderMDXDialog();
            }
            var mdxDialog = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + 'mdx-dialog', document), ej2_popups_1.Dialog);
            var outerDiv = ej2_base_1.createElement('div', {
                className: cls.MDX_QUERY
            });
            var textarea = ej2_base_1.createElement('textarea', {
                className: cls.MDX_QUERY_CONTENT,
                attrs: { 'readonly': 'readonly', 'aria-label': this.parent.localeObj.getConstant('mdxQuery') }
            });
            textarea.innerText = this.parent.olapEngineModule.getMDXQuery(this.parent.dataSourceSettings).trim();
            outerDiv.appendChild(textarea);
            mdxDialog.content = outerDiv;
            mdxDialog.show();
        };
        Toolbar.prototype.dialogShow = function (args, action) {
            Eif (args) {
                var dialog = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', document), ej2_popups_1.Dialog);
                dialog.header = args.item.tooltipText;
                var outerDiv = ej2_base_1.createElement('div', {
                    className: cls.GRID_REPORT_OUTER
                });
                var label = ej2_base_1.createElement('div', {
                    className: cls.GRID_REPORT_LABEL
                });
                label.innerText = this.parent.localeObj.getConstant('reportName');
                var input = ej2_base_1.createElement('input', {
                    className: cls.GRID_REPORT_INPUT + ' ' + cls.INPUT,
                    attrs: {
                        'placeholder': this.parent.localeObj.getConstant('emptyReportName'),
                        'value': (action && action === 'rename' ? this.currentReport : '')
                    }
                });
                input.innerText = (action && action === 'rename' ? this.currentReport : '');
                input.setSelectionRange(input.textContent.length, input.textContent.length);
                outerDiv.appendChild(label);
                outerDiv.appendChild(input);
                dialog.content = outerDiv;
                dialog.refresh();
                dialog.show();
            }
        };
        Toolbar.prototype.renameReport = function (args) {
            this.parent.trigger(events.toolbarClick, args);
            Eif (this.currentReport && this.currentReport !== '') {
                this.dialogShow(args, 'rename');
            }
            else {
                this.parent.pivotCommon.errorDialog.createErrorDialog(this.parent.localeObj.getConstant('error'), this.parent.localeObj.getConstant('emptyReport'));
                return;
            }
        };
        Toolbar.prototype.actionClick = function (args) {
            var actionName = (args.item.id === this.parent.element.id + 'new') ? events.addNewReport : (args.item.id === this.parent.element.id + 'save') ? events.saveCurrentReport : (args.item.id === this.parent.element.id + 'saveas') ? events.saveAsCurrentReport
                : (args.item.id === this.parent.element.id + 'rename') ? events.renameCurrentReport : (args.item.id === this.parent.element.id + 'remove') ? events.removeCurrentReport : (args.item.id === this.parent.element.id + 'load') ? events.loadReports
                    : (args.item.id === this.parent.element.id + 'formatting') ? events.openConditionalFormatting : (args.item.id === this.parent.element.id + 'numberFormatting') ? events.openNumberFormatting
                        : (args.item.id === this.parent.element.id + 'mdxQuery') ? events.MdxQuery : (args.item.id === this.parent.element.id + 'fieldlist') ? events.showFieldList : '';
            this.parent.actionObj.actionName = actionName;
            Iif (this.parent.actionBeginMethod()) {
                return;
            }
            try {
                switch (args.item.id) {
                    case (this.parent.element.id + 'save'):
                    case (this.parent.element.id + 'saveas'):
                        this.saveReport(args);
                        break;
                    case (this.parent.element.id + 'remove'):
                        this.action = 'Remove';
                        Eif (this.currentReport && this.currentReport !== '') {
                            this.createConfirmDialog(this.parent.localeObj.getConstant('alert'), this.parent.localeObj.getConstant('removeConfirm'));
                        }
                        else {
                            this.parent.pivotCommon.errorDialog.createErrorDialog(this.parent.localeObj.getConstant('error'), this.parent.localeObj.getConstant('emptyReport'));
                        }
                        return;
                    case (this.parent.element.id + 'rename'):
                        this.renameReport(args);
                        break;
                    case (this.parent.element.id + 'new'):
                        this.action = 'New';
                        this.newArgs = args;
                        Iif (this.parent.isModified && this.currentReport && this.currentReport !== '') {
                            this.createConfirmDialog(this.parent.localeObj.getConstant('alert'), this.parent.localeObj.getConstant('newReportConfirm'));
                        }
                        else {
                            this.createNewReport(args);
                        }
                        break;
                    case (this.parent.element.id + 'load'):
                        this.action = 'Load';
                        break;
                    case (this.parent.element.id + 'fieldlist'):
                        if (this.parent.pivotFieldListModule && this.parent.pivotFieldListModule.dialogRenderer) {
                            this.parent.pivotFieldListModule.dialogRenderer.onShowFieldList();
                        }
                        break;
                    case (this.parent.element.id + 'formatting'):
                        Eif (this.parent.conditionalFormattingModule) {
                            this.parent.conditionalFormattingModule.showConditionalFormattingDialog();
                        }
                        break;
                    case (this.parent.element.id + 'mdxQuery'):
                        this.mdxQueryDialog();
                        break;
                    case (this.parent.element.id + 'numberFormatting'):
                        Eif (this.parent.numberFormattingModule) {
                            this.parent.numberFormattingModule.showNumberFormattingDialog();
                        }
                        break;
                }
            }
            catch (execption) {
                this.parent.actionFailureMethod(execption);
            }
        };
        Toolbar.prototype.renderDialog = function () {
            Iif (ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', this.parent.element) !== null) {
                ej2_base_1.remove(ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', this.parent.element));
            }
            var reportDialogElement = ej2_base_1.createElement('div', {
                id: this.parent.element.id + 'report-dialog',
                className: cls.GRID_REPORT_DIALOG
            });
            this.parent.element.appendChild(reportDialogElement);
            var dialog = new ej2_popups_1.Dialog({
                animationSettings: { effect: 'Fade' },
                allowDragging: true,
                position: { X: 'center', Y: 'center' },
                buttons: [
                    {
                        click: this.okBtnClick.bind(this),
                        isFlat: false,
                        buttonModel: {
                            content: this.parent.localeObj.getConstant('ok'),
                            isPrimary: true
                        }
                    },
                    {
                        click: this.cancelBtnClick.bind(this),
                        isFlat: false,
                        buttonModel: {
                            content: this.parent.localeObj.getConstant('cancel')
                        }
                    }
                ],
                isModal: true,
                visible: false,
                showCloseIcon: true,
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                width: 'auto',
                height: 'auto',
                zIndex: 1000001,
                closeOnEscape: true,
                target: document.body,
                cssClass: this.parent.cssClass
            });
            dialog.isStringTemplate = true;
            dialog.appendTo(reportDialogElement);
        };
        Toolbar.prototype.renderMDXDialog = function () {
            if (ej2_base_1.select('#' + this.parent.element.id + 'mdx-dialog', this.parent.element) !== null) {
                ej2_base_1.remove(ej2_base_1.select('#' + this.parent.element.id + 'mdx-dialog', this.parent.element));
            }
            var mdxDialogElement = ej2_base_1.createElement('div', {
                id: this.parent.element.id + 'mdx-dialog',
                className: cls.GRID_MDX_DIALOG
            });
            this.parent.element.appendChild(mdxDialogElement);
            var mdxDialog = new ej2_popups_1.Dialog({
                animationSettings: { effect: 'Fade' },
                allowDragging: true,
                position: { X: 'center', Y: 'center' },
                buttons: [
                    {
                        click: this.copyMDXQuery.bind(this),
                        isFlat: false,
                        buttonModel: {
                            content: this.parent.localeObj.getConstant('copy'),
                            isPrimary: true
                        }
                    }
                ],
                header: this.parent.localeObj.getConstant('mdxQuery'),
                isModal: true,
                visible: false,
                showCloseIcon: true,
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                width: 'auto',
                height: 'auto',
                zIndex: 1000001,
                closeOnEscape: true,
                target: document.body,
                cssClass: this.parent.cssClass
            });
            mdxDialog.isStringTemplate = true;
            mdxDialog.appendTo(mdxDialogElement);
        };
        Toolbar.prototype.copyMDXQuery = function () {
            var mdxDialog = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + 'mdx-dialog', document), ej2_popups_1.Dialog);
            var textArea = mdxDialog.element.querySelector('.' + cls.MDX_QUERY_CONTENT);
            try {
                textArea.select();
                document.execCommand('copy');
            }
            catch (err) {
                window.alert('Oops, unable to copy');
            }
            return;
        };
        Toolbar.prototype.okBtnClick = function () {
            var _this_1 = this;
            var dialog = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', document), ej2_popups_1.Dialog);
            var reportInput = dialog.element.querySelector('.' + cls.GRID_REPORT_INPUT);
            if (reportInput && reportInput.value === '') {
                reportInput.focus();
                return;
            }
            Iif (!this.parent.localeObj) {
                this.parent = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id, document), pivotview_1.PivotView);
            }
            if ((dialog.header === this.parent.localeObj.getConstant('save') ||
                dialog.header === this.parent.localeObj.getConstant('saveAs')) &&
                reportInput.value && reportInput.value !== '') {
                this.action = 'Save';
                this.currentReport = reportInput.value;
                var isExist_1 = false;
                var _this_2 = this;
                var reports = { reportName: [] };
                this.parent.trigger(events.fetchReport, reports, function (observedArgs) {
                    for (var i = 0; i < observedArgs.reportName.length; i++) {
                        if (reportInput.value === observedArgs.reportName[i]) {
                            isExist_1 = true;
                            break;
                        }
                    }
                    if (isExist_1) {
                        _this_2.createConfirmDialog(_this_2.parent.localeObj.getConstant('alert'), _this_2.parent.localeObj.getConstant('replaceConfirmBefore') + '"' + reportInput.value + '"' +
                            _this_2.parent.localeObj.getConstant('replaceConfirmAfter'));
                        return;
                    }
                    var saveArgs = {
                        report: _this_2.getCurrentReport(),
                        reportName: reportInput.value
                    };
                    var actionInfo = {
                        reportName: reportInput.value
                    };
                    _this_1.parent.actionObj.actionInfo = actionInfo;
                    _this_2.parent.trigger(events.saveReport, saveArgs);
                    _this_2.parent.isModified = false;
                    _this_2.updateReportList();
                    ej2_base_1.getInstance(ej2_base_1.select('#' + _this_1.parent.element.id + 'report-dialog', document), ej2_popups_1.Dialog).hide();
                });
            }
            else if (dialog.header === this.parent.localeObj.getConstant('new') &&
                reportInput.value && reportInput.value !== '') {
                this.action = 'New';
                this.currentReport = reportInput.value;
                var isExist_2 = false;
                var _this_3 = this;
                var reports_1 = { reportName: [] };
                this.parent.trigger(events.fetchReport, reports_1, function (observedArgs) {
                    for (var i = 0; i < observedArgs.reportName.length; i++) {
                        if (reportInput.value === reports_1.reportName[i]) {
                            isExist_2 = true;
                            break;
                        }
                    }
                    if (isExist_2) {
                        _this_3.createConfirmDialog(_this_3.parent.localeObj.getConstant('alert'), _this_3.parent.localeObj.getConstant('replaceConfirmBefore') + '"' + reportInput.value + '"' +
                            _this_3.parent.localeObj.getConstant('replaceConfirmAfter'));
                        return;
                    }
                    _this_3.parent.trigger(events.newReport);
                    var saveArgs = {
                        report: _this_3.getCurrentReport(),
                        reportName: reportInput.value
                    };
                    var actionInfo = {
                        reportName: reportInput.value
                    };
                    _this_1.parent.actionObj.actionInfo = actionInfo;
                    _this_3.parent.trigger(events.saveReport, saveArgs);
                    _this_3.parent.isModified = false;
                    _this_3.updateReportList();
                    ej2_base_1.getInstance(ej2_base_1.select('#' + _this_1.parent.element.id + 'report-dialog', document), ej2_popups_1.Dialog).hide();
                });
            }
            else Eif (dialog.header === this.parent.localeObj.getConstant('rename') && reportInput.value && reportInput.value !== '') {
                if (this.currentReport === reportInput.value) {
                    dialog.hide();
                    return;
                }
                this.action = 'Rename';
                var isExist = false;
                this.renameText = reportInput.value;
                var reports = this.fetchReports();
                for (var i = 0; i < reports.reportName.length; i++) {
                    Iif (reportInput.value === reports.reportName[i]) {
                        isExist = true;
                        break;
                    }
                }
                Iif (isExist) {
                    this.createConfirmDialog(this.parent.localeObj.getConstant('alert'), this.parent.localeObj.getConstant('replaceConfirmBefore') + '"' + reportInput.value + '"' +
                        this.parent.localeObj.getConstant('replaceConfirmAfter'));
                    return;
                }
                var renameArgs = {
                    reportName: this.currentReport,
                    rename: reportInput.value
                };
                var actionInfo = {
                    reportName: { oldName: this.currentReport, newName: reportInput.value }
                };
                this.parent.actionObj.actionInfo = actionInfo;
                this.parent.trigger(events.renameReport, renameArgs);
                this.currentReport = reportInput.value;
                this.updateReportList();
                dialog.hide();
            }
            this.parent.actionObj.actionName = this.parent.getActionCompleteName();
            Eif (this.parent.actionObj.actionName) {
                this.parent.actionCompleteMethod();
            }
        };
        Toolbar.prototype.createNewReport = function (args) {
            this.dialogShow(args);
        };
        Toolbar.prototype.cancelBtnClick = function () {
            var dialog = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', document), ej2_popups_1.Dialog);
            dialog.hide();
        };
        Toolbar.prototype.createConfirmDialog = function (title, description) {
            if (document.getElementById(this.parent.element.id + '_ConfirmDialog')) {
                ej2_base_1.remove(document.getElementById(this.parent.element.id + '_ConfirmDialog').parentElement);
            }
            var errorDialog = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_ConfirmDialog',
                className: cls.ERROR_DIALOG_CLASS
            });
            this.parent.element.appendChild(errorDialog);
            var confirmPopUp = new ej2_popups_1.Dialog({
                animationSettings: { effect: 'Fade' },
                allowDragging: true,
                showCloseIcon: true,
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                header: title,
                content: description,
                isModal: true,
                visible: true,
                closeOnEscape: true,
                target: document.body,
                cssClass: this.parent.cssClass,
                width: 'auto',
                height: 'auto',
                position: { X: 'center', Y: 'center' },
                buttons: [
                    {
                        isFlat: false,
                        buttonModel: {
                            content: this.parent.localeObj.getConstant('yes'), isPrimary: true,
                            cssClass: cls.OK_BUTTON_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : '')
                        },
                        click: this.okButtonClick.bind(this)
                    },
                    {
                        isFlat: false,
                        buttonModel: {
                            content: this.parent.localeObj.getConstant('no'),
                            cssClass: cls.CANCEL_BUTTON_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : '')
                        },
                        click: this.cancelButtonClick.bind(this)
                    }
                ]
            });
            confirmPopUp.isStringTemplate = true;
            confirmPopUp.appendTo(errorDialog);
            confirmPopUp.element.querySelector('.e-dlg-header').innerText = this.parent.enableHtmlSanitizer ? ej2_base_1.SanitizeHtmlHelper.sanitize(title) : title;
        };
        Toolbar.prototype.okButtonClick = function () {
            var _this_1 = this;
            var dialog = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', document), ej2_popups_1.Dialog);
            if (this.action === 'Remove') {
                var removeArgs = {
                    reportName: this.currentReport
                };
                var actionInfo = {
                    reportName: this.currentReport
                };
                this.parent.actionObj.actionInfo = actionInfo;
                this.parent.trigger(events.removeReport, removeArgs);
                var reports = this.fetchReports();
                Eif (reports.reportName && reports.reportName.length > 0) {
                    var loadArgs = {
                        reportName: reports.reportName[reports.reportName.length - 1]
                    };
                    this.parent.trigger(events.loadReport, loadArgs, function (observedArgs) {
                        _this_1.currentReport = observedArgs.reportName;
                        _this_1.parent.isModified = false;
                    });
                    this.currentReport = reports.reportName[reports.reportName.length - 1];
                }
                else {
                    this.currentReport = '';
                    this.parent.isModified = false;
                    this.action = '';
                }
                this.updateReportList();
                this.parent.actionObj.actionName = events.reportRemoved;
                Eif (this.parent.actionObj.actionName) {
                    this.parent.actionCompleteMethod();
                }
            }
            else Eif (this.action === 'New' || (this.action !== 'Save' && this.action !== 'Rename' && this.action !== 'New')) {
                Iif (this.currentReport && this.currentReport !== '' && this.parent.isModified) {
                    var saveArgs = {
                        report: this.getCurrentReport(),
                        reportName: this.currentReport
                    };
                    var actionInfo = {
                        reportName: this.currentReport
                    };
                    this.parent.actionObj.actionInfo = actionInfo;
                    this.parent.actionObj.actionName = events.reportSaved;
                    if (this.parent.actionObj.actionName) {
                        this.parent.actionCompleteMethod();
                    }
                    this.parent.trigger(events.saveReport, saveArgs);
                    this.parent.isModified = false;
                    if (this.action === 'New') {
                        this.parent.actionObj.actionName = events.addNewReport;
                        this.createNewReport(this.newArgs);
                    }
                    else {
                        this.parent.actionObj.actionName = events.reportChange;
                        this.reportLoad(this.dropArgs);
                    }
                }
                else Eif (this.action === 'New') {
                    this.parent.trigger(events.newReport);
                    var saveArgs = {
                        report: this.getCurrentReport(),
                        reportName: this.currentReport
                    };
                    this.parent.trigger(events.saveReport, saveArgs);
                    this.parent.isModified = false;
                    this.updateReportList();
                    dialog.hide();
                }
            }
            else if (this.action === 'Save') {
                var saveArgs = {
                    report: this.getCurrentReport(),
                    reportName: this.currentReport
                };
                this.parent.trigger(events.saveReport, saveArgs);
                this.parent.isModified = false;
                this.updateReportList();
                dialog.hide();
            }
            else if (this.action === 'Rename') {
                var renameArgs = {
                    reportName: this.currentReport,
                    rename: this.renameText,
                    isReportExists: true
                };
                this.parent.trigger(events.renameReport, renameArgs);
                this.currentReport = this.renameText;
                this.parent.isModified = false;
                this.updateReportList();
                dialog.hide();
            }
            var confirmPopUp = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_ConfirmDialog', document), ej2_popups_1.Dialog);
            confirmPopUp.hide();
        };
        Toolbar.prototype.cancelButtonClick = function () {
            var dialog = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', document), ej2_popups_1.Dialog);
            if (this.action === 'New') {
                Iif (this.parent.isModified) {
                    this.createNewReport(this.newArgs);
                }
                else {
                    dialog.hide();
                }
            }
            else if (this.action === 'Save') {
                Eif (ej2_base_1.select('#' + this.parent.element.id + '_reportlist', this.parent.element)) {
                    var reportList = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_reportlist', this.parent.element), ej2_dropdowns_1.DropDownList);
                    this.currentReport = reportList.value;
                }
                dialog.hide();
            }
            else Iif (this.action === 'Rename') {
                dialog.hide();
            }
            else Iif (this.dropArgs && this.action !== 'Remove') {
                this.reportLoad(this.dropArgs);
            }
            var confirmPopUp = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_ConfirmDialog', document), ej2_popups_1.Dialog);
            confirmPopUp.hide();
        };
        Toolbar.prototype.createChartMenu = function () {
            var _this_1 = this;
            Eif (ej2_base_1.select('#' + this.parent.element.id + 'chart_menu', this.parent.element)) {
                var chartMenuElement = ej2_base_1.select('#' + this.parent.element.id + 'chart_menu', this.parent.element);
                var menuItems = [];
                var types = this.getValidChartType();
                for (var i = 0; (i < types.length && i < 7); i++) {
                    var type = types[i];
                    menuItems.push({
                        text: this.parent.localeObj.getConstant(type.toLowerCase()),
                        id: this.parent.element.id + '_' + type
                    });
                }
                Eif (menuItems.length === 7) {
                    menuItems.splice(6);
                    menuItems.push({
                        text: this.parent.localeObj.getConstant('MoreOption'),
                        id: this.parent.element.id + '_' + 'ChartMoreOption'
                    });
                }
                var toDisable = (menuItems.length <= 0 || this.parent.displayOption.view === 'Table');
                menuItems.push({
                    separator: true
                });
                menuItems.push({
                    text: this.parent.localeObj.getConstant('multipleAxes'),
                    id: this.parent.element.id + '_' + 'multipleAxes'
                });
                menuItems.push({
                    text: this.parent.localeObj.getConstant('showLegend'),
                    id: this.parent.element.id + '_' + 'showLegend'
                });
                var menu = [{
                        iconCss: cls.TOOLBAR_CHART + ' ' + cls.ICON,
                        items: toDisable ? [] : menuItems
                    }];
                var chartMenu = chartMenuElement ? ej2_base_1.getInstance(chartMenuElement, ej2_navigations_1.Menu) : null;
                Iif (chartMenu && !chartMenu.isDestroyed) {
                    chartMenu.destroy();
                    chartMenu = null;
                }
                chartMenu = new ej2_navigations_1.Menu({
                    items: menu, enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale,
                    enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                    cssClass: cls.TOOLBAR_MENU + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    select: this.menuItemClick.bind(this),
                    beforeOpen: this.whitespaceRemove.bind(this),
                    onClose: function () {
                        _this_1.focusToolBar();
                    },
                    beforeItemRender: this.multipleAxesCheckbox.bind(this)
                });
                chartMenu.isStringTemplate = true;
                chartMenu.appendTo(chartMenuElement);
            }
        };
        Toolbar.prototype.create = function () {
            var _this_1 = this;
            if (ej2_base_1.select('#' + this.parent.element.id + 'chart_menu', this.parent.element)) {
                this.createChartMenu();
            }
            if (ej2_base_1.select('#' + this.parent.element.id + 'export_menu', this.parent.element)) {
                var exportMenuElement = ej2_base_1.select('#' + this.parent.element.id + 'export_menu', this.parent.element);
                var menu = [{
                        iconCss: cls.GRID_EXPORT + ' ' + cls.ICON,
                        items: [
                            {
                                text: this.parent.localeObj.getConstant('pdf'),
                                iconCss: cls.GRID_PDF_EXPORT + ' ' + cls.ICON,
                                id: this.parent.element.id + 'pdf'
                            },
                            {
                                text: this.parent.localeObj.getConstant('excel'),
                                iconCss: cls.GRID_EXCEL_EXPORT + ' ' + cls.ICON,
                                id: this.parent.element.id + 'excel'
                            },
                            {
                                text: this.parent.localeObj.getConstant('csv'),
                                iconCss: cls.GRID_CSV_EXPORT + ' ' + cls.ICON,
                                id: this.parent.element.id + 'csv'
                            },
                            {
                                text: this.parent.localeObj.getConstant('png'),
                                iconCss: cls.GRID_PNG_EXPORT + ' ' + cls.ICON,
                                id: this.parent.element.id + 'png'
                            },
                            {
                                text: this.parent.localeObj.getConstant('jpeg'),
                                iconCss: cls.GRID_JPEG_EXPORT + ' ' + cls.ICON,
                                id: this.parent.element.id + 'jpeg'
                            },
                            {
                                text: this.parent.localeObj.getConstant('svg'),
                                iconCss: cls.GRID_SVG_EXPORT + ' ' + cls.ICON,
                                id: this.parent.element.id + 'svg'
                            }
                        ]
                    }];
                var exportMenu = new ej2_navigations_1.Menu({
                    items: menu, enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale, enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                    cssClass: cls.TOOLBAR_MENU + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    select: this.menuItemClick.bind(this), beforeOpen: this.updateExportMenu.bind(this),
                    onClose: function () {
                        _this_1.focusToolBar();
                    }
                });
                exportMenu.isStringTemplate = true;
                exportMenu.appendTo(exportMenuElement);
            }
            if (ej2_base_1.select('#' + this.parent.element.id + 'subtotal_menu', this.parent.element)) {
                var subTotalMenuElement = ej2_base_1.select('#' + this.parent.element.id + 'subtotal_menu', this.parent.element);
                var menu = [{
                        iconCss: cls.GRID_SUB_TOTAL + ' ' + cls.ICON,
                        items: [
                            {
                                text: this.parent.localeObj.getConstant('showSubTotals'),
                                id: this.parent.element.id + 'subtotal',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                text: this.parent.localeObj.getConstant('doNotShowSubTotals'),
                                id: this.parent.element.id + 'notsubtotal',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                text: this.parent.localeObj.getConstant('showSubTotalsRowsOnly'),
                                id: this.parent.element.id + 'subtotalrow',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                text: this.parent.localeObj.getConstant('showSubTotalsColumnsOnly'),
                                id: this.parent.element.id + 'subtotalcolumn',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                separator: true
                            },
                            {
                                text: this.parent.localeObj.getConstant('subTotalPosition'),
                                id: this.parent.element.id + 'subtotalpositions',
                                iconCss: cls.PIVOT_DISABLE_ICON + ' ' + cls.ICON,
                                items: [
                                    {
                                        text: this.parent.localeObj.getConstant('auto'),
                                        id: this.parent.element.id + 'sub-none-position',
                                        iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                                    },
                                    {
                                        text: this.parent.localeObj.getConstant('top'),
                                        id: this.parent.element.id + 'sub-top-position',
                                        iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                                    },
                                    {
                                        text: this.parent.localeObj.getConstant('bottom'),
                                        id: this.parent.element.id + 'sub-bottom-position',
                                        iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                                    }
                                ]
                            }
                        ]
                    }];
                var subTotalMenu = new ej2_navigations_1.Menu({
                    items: menu, enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale, enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                    cssClass: cls.TOOLBAR_MENU + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    select: this.menuItemClick.bind(this), beforeOpen: this.updateSubtotalSelection.bind(this),
                    onClose: function () {
                        _this_1.focusToolBar();
                    }
                });
                subTotalMenu.isStringTemplate = true;
                subTotalMenu.appendTo(subTotalMenuElement);
            }
            if (ej2_base_1.select('#' + this.parent.element.id + 'grandtotal_menu', this.parent.element)) {
                var grandTotalMenuElement = ej2_base_1.select('#' + this.parent.element.id + 'grandtotal_menu', this.parent.element);
                var menu = [{
                        iconCss: cls.GRID_GRAND_TOTAL + ' ' + cls.ICON,
                        items: [
                            {
                                text: this.parent.localeObj.getConstant('showGrandTotals'),
                                id: this.parent.element.id + 'grandtotal',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                text: this.parent.localeObj.getConstant('doNotShowGrandTotals'),
                                id: this.parent.element.id + 'notgrandtotal',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                text: this.parent.localeObj.getConstant('showGrandTotalsRowsOnly'),
                                id: this.parent.element.id + 'grandtotalrow',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                text: this.parent.localeObj.getConstant('showGrandTotalsColumnsOnly'),
                                id: this.parent.element.id + 'grandtotalcolumn',
                                iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                            },
                            {
                                separator: true
                            },
                            {
                                text: this.parent.localeObj.getConstant('grandTotalPosition'),
                                id: this.parent.element.id + 'grandtotalpositions',
                                iconCss: cls.PIVOT_DISABLE_ICON + ' ' + cls.ICON,
                                items: [
                                    {
                                        text: this.parent.localeObj.getConstant('top'),
                                        id: this.parent.element.id + 'top-position',
                                        iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                                    },
                                    {
                                        text: this.parent.localeObj.getConstant('bottom'),
                                        id: this.parent.element.id + 'bottom-position',
                                        iconCss: cls.PIVOT_SELECT_ICON + ' ' + cls.ICON
                                    }
                                ]
                            }
                        ]
                    }];
                var grandTotalMenu = new ej2_navigations_1.Menu({
                    items: menu, enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale, enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                    cssClass: cls.TOOLBAR_MENU + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    select: this.menuItemClick.bind(this), beforeOpen: this.updateGrandtotalSelection.bind(this),
                    onClose: function () {
                        _this_1.focusToolBar();
                    }
                });
                grandTotalMenu.isStringTemplate = true;
                grandTotalMenu.appendTo(grandTotalMenuElement);
            }
            Iif (ej2_base_1.select('#' + this.parent.element.id + 'formatting_menu', this.parent.element)) {
                var formattingMenuElement = ej2_base_1.select('#' + this.parent.element.id + 'formatting_menu', this.parent.element);
                var menu = [{
                        iconCss: cls.FORMATTING_MENU + ' ' + cls.ICON,
                        items: [
                            {
                                text: this.parent.localeObj.getConstant('numberFormatMenu'),
                                iconCss: cls.NUMBER_FORMATTING_MENU + ' ' + cls.ICON,
                                id: this.parent.element.id + 'numberFormattingMenu'
                            },
                            {
                                text: this.parent.localeObj.getConstant('conditionalFormattingMenu'),
                                iconCss: cls.CONDITIONAL_FORMATTING_MENU + ' ' + cls.ICON,
                                id: this.parent.element.id + 'conditionalFormattingMenu'
                            }
                        ]
                    }];
                var formattingMenu = new ej2_navigations_1.Menu({
                    items: menu, enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale, enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                    cssClass: cls.TOOLBAR_MENU + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    select: this.menuItemClick.bind(this)
                });
                formattingMenu.isStringTemplate = true;
                formattingMenu.appendTo(formattingMenuElement);
            }
            var saveArgs = {
                report: this.parent.getPersistData(),
                reportName: this.parent.localeObj.getConstant('defaultReport')
            };
            this.currentReport = this.parent.localeObj.getConstant('defaultReport');
            this.parent.trigger(events.saveReport, saveArgs);
            if (ej2_base_1.select('#' + this.parent.element.id + '_reportlist', this.parent.element)) {
                var reportListElement = ej2_base_1.select('#' + this.parent.element.id + '_reportlist', this.parent.element);
                var reports = this.fetchReports();
                var reportList = new ej2_dropdowns_1.DropDownList({
                    dataSource: reports.reportName,
                    width: '150px',
                    popupHeight: '200px',
                    placeholder: this.currentReport === '' ? this.parent.localeObj.getConstant('reportList') : '',
                    enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale,
                    cssClass: cls.REPORT_LIST_DROP + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    select: this.reportChange.bind(this),
                    value: this.currentReport
                });
                reportList.isStringTemplate = true;
                reportList.appendTo(reportListElement);
            }
            this.updateItemElements();
        };
        Toolbar.prototype.getCurrentReport = function () {
            var reportStr = this.parent.getPersistData();
            Iif (this.parent.dataSourceSettings.type === 'CSV' && this.parent.dataSourceSettings.mode !== 'Server') {
                var reportSettings = JSON.parse(reportStr);
                reportSettings.dataSourceSettings.dataSource.splice(0, 0, this.parent.engineModule.fields);
                reportStr = JSON.stringify(reportSettings);
            }
            return reportStr;
        };
        Toolbar.prototype.updateItemElements = function () {
            var itemElements = [].slice.call(this.toolbar.element.querySelectorAll('.e-toolbar-item'));
            for (var _i = 0, itemElements_1 = itemElements; _i < itemElements_1.length; _i++) {
                var element = itemElements_1[_i];
                if (element.querySelector('button')) {
                    element.querySelector('button').setAttribute('tabindex', '0');
                }
                else if (element.querySelector('.e-menu.e-menu-parent')) {
                    element.querySelector('.e-menu.e-menu-parent').setAttribute('tabindex', '-1');
                    Eif (element.querySelector('.e-menu-item.e-menu-caret-icon')) {
                        element.querySelector('.e-menu-item.e-menu-caret-icon').setAttribute('tabindex', '0');
                    }
                }
            }
        };
        Toolbar.prototype.whitespaceRemove = function (args) {
            var separator = args.element.querySelector('.e-separator');
            Eif (separator) {
                separator.style.margin = '0px';
            }
        };
        Toolbar.prototype.multipleAxesCheckbox = function (args) {
            var _this_1 = this;
            if (this.parent.element.id + '_' + 'multipleAxes' === args.element.id) {
                var inputCheckbox = ej2_base_1.createElement('input', {
                    id: this.parent.element.id + '_' + 'checkBox'
                });
                inputCheckbox.style.display = 'none';
                this.parent.element.appendChild(inputCheckbox);
                var checkbox = new ej2_buttons_1.CheckBox({
                    label: this.parent.localeObj.getConstant('multipleAxes'),
                    cssClass: 'e-multipleAxes' + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    checked: this.parent.chartSettings.enableMultipleAxis,
                    change: function () {
                        document.getElementById(_this_1.parent.element.id + '_' + 'multipleAxes').click();
                    },
                    enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale,
                    enableHtmlSanitizer: this.parent.enableHtmlSanitizer
                });
                args.element.innerText = '';
                checkbox.appendTo(inputCheckbox);
                Iif ((['Pie', 'Funnel', 'Pyramid', 'Doughnut', 'Pareto'].indexOf(this.parent.chartSettings.chartSeries.type) > -1) &&
                    !args.element.classList.contains(cls.MENU_DISABLE)) {
                    args.element.classList.add(cls.MENU_DISABLE);
                    checkbox.disabled = true;
                }
                else Iif ((['Pie', 'Funnel', 'Pyramid', 'Doughnut', 'Pareto'].indexOf(this.parent.chartSettings.chartSeries.type) < 0) &&
                    args.element.classList.contains(cls.MENU_DISABLE)) {
                    args.element.classList.remove(cls.MENU_DISABLE);
                    checkbox.disabled = false;
                }
                var checkboxObj = this.parent.element.querySelector('.' + cls.CHECKBOX_CONTAINER + '.e-multipleAxes');
                args.element.appendChild(checkboxObj);
            }
            else if (this.parent.element.id + '_' + 'showLegend' === args.element.id) {
                var inputCheckbox = ej2_base_1.createElement('input', {
                    id: this.parent.element.id + '_' + 'showLegendCheckBox'
                });
                inputCheckbox.style.display = 'none';
                this.parent.element.appendChild(inputCheckbox);
                var checkbox = new ej2_buttons_1.CheckBox({
                    label: this.parent.localeObj.getConstant('showLegend'),
                    checked: this.getLableState(),
                    cssClass: 'e-showLegend' + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                    change: function () {
                        document.getElementById(_this_1.parent.element.id + '_' + 'showLegend').click();
                    },
                    enableRtl: this.parent.enableRtl,
                    locale: this.parent.locale,
                    enableHtmlSanitizer: this.parent.enableHtmlSanitizer
                });
                args.element.innerText = '';
                checkbox.appendTo(inputCheckbox);
                var checkboxObj = this.parent.element.querySelector('.' + cls.CHECKBOX_CONTAINER + '.e-showLegend');
                args.element.appendChild(checkboxObj);
            }
        };
        Toolbar.prototype.getLableState = function () {
            var chartSettings = JSON.parse(this.parent.getChartSettings()).chartSettings;
            Iif (chartSettings && chartSettings.legendSettings && chartSettings.legendSettings.visible !== undefined) {
                this.showLableState = chartSettings.legendSettings.visible;
            }
            else {
                this.showLableState = true;
            }
            return this.showLableState;
        };
        Toolbar.prototype.getAllChartItems = function () {
            return ['Line', 'Column', 'Area', 'Bar', 'StackingColumn', 'StackingArea', 'StackingBar', 'StackingLine', 'StepLine', 'StepArea',
                'SplineArea', 'Scatter', 'Spline', 'StackingColumn100', 'StackingBar100', 'StackingArea100', 'StackingLine100', 'Bubble', 'Pareto',
                'Polar', 'Radar', 'Pie', 'Pyramid', 'Funnel', 'Doughnut'];
        };
        Toolbar.prototype.updateExportMenu = function (args) {
            var items = [].slice.call(args.element.querySelectorAll('li'));
            if (this.parent.currentView === 'Table') {
                ej2_base_1.addClass(items.slice(3), cls.MENU_HIDE);
                ej2_base_1.removeClass(items.slice(1, 3), cls.MENU_HIDE);
            }
            else {
                ej2_base_1.addClass(items.slice(1, 3), cls.MENU_HIDE);
                ej2_base_1.removeClass(items.slice(3), cls.MENU_HIDE);
            }
        };
        Toolbar.prototype.updateSubtotalSelection = function (args) {
            if (!(args.parentItem.id === this.parent.element.id + 'subtotalpositions')) {
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'subtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'subtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'notsubtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'notsubtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'subtotalrow' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'subtotalrow' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'subtotalcolumn' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'subtotalcolumn' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                if (this.parent.dataSourceSettings.showSubTotals && this.parent.dataSourceSettings.showRowSubTotals &&
                    !this.parent.dataSourceSettings.showColumnSubTotals) {
                    ej2_base_1.select('#' + this.parent.element.id + 'subtotalrow' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                else if (this.parent.dataSourceSettings.showSubTotals && !this.parent.dataSourceSettings.showRowSubTotals &&
                    this.parent.dataSourceSettings.showColumnSubTotals) {
                    ej2_base_1.select('#' + this.parent.element.id + 'subtotalcolumn' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                else if (this.parent.dataSourceSettings.showSubTotals && this.parent.dataSourceSettings.showRowSubTotals &&
                    this.parent.dataSourceSettings.showColumnSubTotals) {
                    ej2_base_1.select('#' + this.parent.element.id + 'subtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                else Eif (!this.parent.dataSourceSettings.showSubTotals || (!this.parent.dataSourceSettings.showRowSubTotals &&
                    !this.parent.dataSourceSettings.showColumnSubTotals)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'notsubtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
            }
            else {
                ej2_base_1.select('#' + this.parent.element.id + 'sub-none-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                if (this.parent.dataSourceSettings.subTotalsPosition === 'Auto') {
                    ej2_base_1.select('#' + this.parent.element.id + 'sub-none-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                ej2_base_1.select('#' + this.parent.element.id + 'sub-top-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                if (this.parent.dataSourceSettings.subTotalsPosition === 'Top') {
                    ej2_base_1.select('#' + this.parent.element.id + 'sub-top-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                ej2_base_1.select('#' + this.parent.element.id + 'sub-bottom-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                Iif (this.parent.dataSourceSettings.subTotalsPosition === 'Bottom') {
                    ej2_base_1.select('#' + this.parent.element.id + 'sub-bottom-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
            }
        };
        Toolbar.prototype.updateGrandtotalSelection = function (args) {
            if (!(args.parentItem.id === this.parent.element.id + 'grandtotalpositions')) {
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'grandtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'grandtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'notgrandtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'notgrandtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'grandtotalrow' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'grandtotalrow' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                Eif (!ej2_base_1.select('#' + this.parent.element.id + 'grandtotalcolumn' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.contains(cls.PIVOT_DISABLE_ICON)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'grandtotalcolumn' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                }
                if (this.parent.dataSourceSettings.showGrandTotals && this.parent.dataSourceSettings.showRowGrandTotals &&
                    !this.parent.dataSourceSettings.showColumnGrandTotals) {
                    ej2_base_1.select('#' + this.parent.element.id + 'grandtotalrow' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                else if (this.parent.dataSourceSettings.showGrandTotals && !this.parent.dataSourceSettings.showRowGrandTotals &&
                    this.parent.dataSourceSettings.showColumnGrandTotals) {
                    ej2_base_1.select('#' + this.parent.element.id + 'grandtotalcolumn' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                else if (this.parent.dataSourceSettings.showGrandTotals && this.parent.dataSourceSettings.showRowGrandTotals &&
                    this.parent.dataSourceSettings.showColumnGrandTotals) {
                    ej2_base_1.select('#' + this.parent.element.id + 'grandtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                else Eif (!this.parent.dataSourceSettings.showGrandTotals || (!this.parent.dataSourceSettings.showRowGrandTotals &&
                    !this.parent.dataSourceSettings.showColumnGrandTotals)) {
                    ej2_base_1.select('#' + this.parent.element.id + 'notgrandtotal' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
            }
            else {
                ej2_base_1.select('#' + this.parent.element.id + 'top-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                Iif (this.parent.dataSourceSettings.grandTotalsPosition === 'Top') {
                    ej2_base_1.select('#' + this.parent.element.id + 'top-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
                ej2_base_1.select('#' + this.parent.element.id + 'bottom-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.add(cls.PIVOT_DISABLE_ICON);
                Eif (this.parent.dataSourceSettings.grandTotalsPosition === 'Bottom') {
                    ej2_base_1.select('#' + this.parent.element.id + 'bottom-position' + ' .' + cls.PIVOT_SELECT_ICON, args.element).classList.remove(cls.PIVOT_DISABLE_ICON);
                }
            }
        };
        Toolbar.prototype.updateReportList = function () {
            Eif (ej2_base_1.select('#' + this.parent.element.id + '_reportlist', this.parent.element)) {
                var reports = this.fetchReports();
                var reportList = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_reportlist', this.parent.element), ej2_dropdowns_1.DropDownList);
                reportList.dataSource = reports.reportName;
                Iif (this.currentReport === '' && reportList.dataSource.length > 0) {
                    reportList.value = reportList.dataSource[reportList.dataSource.length - 1];
                    reportList.text = reportList.dataSource[reportList.dataSource.length - 1];
                    this.currentReport = reportList.dataSource[reportList.dataSource.length - 1];
                }
                else {
                    reportList.value = this.currentReport;
                    reportList.text = this.currentReport;
                }
                reportList.refresh();
            }
        };
        Toolbar.prototype.menuItemClick = function (args) {
            var _this_1 = this;
            var exportArgs = {};
            var type;
            var actionName = (args.item.id === this.parent.element.id + 'grid') ? events.tableView : (args.item.id === this.parent.element.id + '_' + 'Column') ? events.chartView : (args.item.id === this.parent.element.id + '_' + 'Bar') ? events.chartView : (args.item.id === this.parent.element.id + '_' + 'Line') ? events.chartView
                : (args.item.id === this.parent.element.id + '_' + 'Area') ? events.chartView : (args.item.id === this.parent.element.id + '_' + 'Scatter') ? events.chartView : (args.item.id === this.parent.element.id + '_' + 'Polar') ? events.chartView : (args.item.id === this.parent.element.id + '_' + 'ChartMoreOption') ? events.chartView
                    : (args.item.id === this.parent.element.id + '_' + 'multipleAxes') ? events.multipleAxis : (args.item.id === this.parent.element.id + '_' + 'showLegend') ? events.showLegend : (args.item.id === this.parent.element.id + 'pdf') ? events.pdfExport : (args.item.id === this.parent.element.id + 'png') ? events.pngExport
                        : (args.item.id === this.parent.element.id + 'excel') ? events.excelExport : (args.item.id === this.parent.element.id + 'csv') ? events.csvExport : (args.item.id === this.parent.element.id + 'jpeg') ? events.jpegExport : (args.item.id === this.parent.element.id + 'svg') ? events.svgExport
                            : (args.item.id === this.parent.element.id + 'notsubtotal') ? events.hideSubTotals : (args.item.id === this.parent.element.id + 'subtotalrow') ? events.subTotalsRow : (args.item.id === this.parent.element.id + 'subtotalcolumn') ? events.subTotalsColumn
                                : (args.item.id === this.parent.element.id + 'subtotal') ? events.showSubTotals : (args.item.id === this.parent.element.id + 'notgrandtotal') ? events.hideGrandTotals : (args.item.id === this.parent.element.id + 'grandtotalrow') ? events.grandTotalsRow
                                    : (args.item.id === this.parent.element.id + 'grandtotalcolumn') ? events.grandTotalsColumn : (args.item.id === this.parent.element.id + 'grandtotal') ? events.showGrandTotals
                                        : (args.item.id === this.parent.element.id + 'numberFormattingMenu') ? events.numberFormattingMenu : (args.item.id === this.parent.element.id + 'conditionalFormattingMenu') ? events.conditionalFormattingMenu : '';
            this.parent.actionObj.actionName = actionName;
            if (this.parent.actionBeginMethod()) {
                return;
            }
            if (this.getAllChartItems().indexOf(args.item.id.split(this.parent.element.id + '_')[1]) > -1 ||
                (args.item.id.split(this.parent.element.id + '_')[1] === 'ChartMoreOption') ||
                (args.item.id.split(this.parent.element.id + '_')[1] === 'multipleAxes') ||
                (args.item.id.split(this.parent.element.id + '_')[1] === 'showLegend')) {
                type = args.item.id.split(this.parent.element.id + '_')[1];
            }
            try {
                switch (args.item.id) {
                    case (this.parent.element.id + 'grid'):
                        Eif (this.parent.grid && this.parent.chart) {
                            this.parent.grid.element.style.display = '';
                            this.parent.chart.element.style.display = 'none';
                            Iif (this.parent.chartSettings.enableMultipleAxis && this.parent.chartSettings.enableScrollOnMultiAxis) {
                                this.parent.element.querySelector('.e-pivotchart').style.display = 'none';
                            }
                            this.parent.currentView = 'Table';
                            this.parent.setProperties({ displayOption: { primary: 'Table' } }, true);
                            Eif (this.parent.showGroupingBar && this.parent.groupingBarModule) {
                                Eif (this.parent.element.querySelector('.e-pivot-grouping-bar')) {
                                    this.parent.element.querySelector('.e-pivot-grouping-bar').style.display = '';
                                }
                                Eif (this.parent.element.querySelector('.e-chart-grouping-bar')) {
                                    this.parent.element.querySelector('.e-chart-grouping-bar').style.display = 'none';
                                }
                            }
                            var actionInfo = {
                                toolbarInfo: {
                                    displayOption: this.parent.displayOption,
                                    gridSettings: this.parent.gridSettings
                                }
                            };
                            this.parent.actionObj.actionInfo = actionInfo;
                            this.parent.layoutRefresh();
                        }
                        break;
                    case (this.parent.element.id + 'pdf'):
                        if (this.parent.currentView === 'Table') {
                            this.parent.pdfExport({ fileName: 'Export.pdf' }, false, undefined, false);
                        }
                        else {
                            this.parent.chartExport('PDF', { fileName: 'result' }, undefined, null, undefined);
                        }
                        break;
                    case (this.parent.element.id + 'excel'):
                        exportArgs = {
                            excelExportProperties: { fileName: 'Export.xlsx' },
                            isBlob: undefined,
                            isMultipleExport: undefined,
                            workbook: undefined
                        };
                        this.parent.trigger(events.beforeExport, exportArgs, function (observedArgs) {
                            _this_1.parent.excelExport(observedArgs.excelExportProperties, observedArgs.isMultipleExport, observedArgs.workbook, observedArgs.isBlob);
                        });
                        break;
                    case (this.parent.element.id + 'csv'):
                        exportArgs = {
                            excelExportProperties: { fileName: 'Export.csv' },
                            isBlob: false,
                            isMultipleExport: false,
                            workbook: undefined
                        };
                        this.parent.trigger(events.beforeExport, exportArgs, function (observedArgs) {
                            Iif (_this_1.parent.dataSourceSettings.mode === 'Server') {
                                _this_1.parent.getEngine('onCsvExport', null, null, null, null, null, null, null, null, observedArgs.excelExportProperties);
                            }
                            else {
                                _this_1.parent.csvExport(observedArgs.excelExportProperties, observedArgs.isMultipleExport, observedArgs.workbook, observedArgs.isBlob);
                            }
                        });
                        break;
                    case (this.parent.element.id + 'png'):
                        this.parent.chartExport('PNG', { fileName: 'result' }, undefined, null, undefined);
                        break;
                    case (this.parent.element.id + 'jpeg'):
                        this.parent.chartExport('JPEG', { fileName: 'result' }, undefined, null, undefined);
                        break;
                    case (this.parent.element.id + 'svg'):
                        this.parent.chartExport('SVG', { fileName: 'result' }, undefined, null, undefined);
                        break;
                    case (this.parent.element.id + 'notsubtotal'):
                        this.parent.setProperties({ dataSourceSettings: { showSubTotals: false, showColumnSubTotals: false, showRowSubTotals: false } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'subtotalrow'):
                        this.parent.setProperties({ dataSourceSettings: { showSubTotals: true, showColumnSubTotals: false, showRowSubTotals: true } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'subtotalcolumn'):
                        this.parent.setProperties({ dataSourceSettings: { showSubTotals: true, showColumnSubTotals: true, showRowSubTotals: false } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'subtotal'):
                        this.parent.setProperties({ dataSourceSettings: { showSubTotals: true, showColumnSubTotals: true, showRowSubTotals: true } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'notgrandtotal'):
                        this.parent.setProperties({ dataSourceSettings: { showGrandTotals: false, showColumnGrandTotals: false, showRowGrandTotals: false } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'grandtotalrow'):
                        this.parent.setProperties({ dataSourceSettings: { showGrandTotals: true, showColumnGrandTotals: false, showRowGrandTotals: true } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'grandtotalcolumn'):
                        this.parent.setProperties({ dataSourceSettings: { showGrandTotals: true, showColumnGrandTotals: true, showRowGrandTotals: false } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'grandtotal'):
                        this.parent.setProperties({ dataSourceSettings: { showGrandTotals: true, showColumnGrandTotals: true, showRowGrandTotals: true } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'top-position'):
                        this.parent.setProperties({ dataSourceSettings: { grandTotalsPosition: 'Top' } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'bottom-position'):
                        this.parent.setProperties({ dataSourceSettings: { grandTotalsPosition: 'Bottom' } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'sub-top-position'):
                        this.parent.setProperties({ dataSourceSettings: { subTotalsPosition: 'Top' } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'sub-bottom-position'):
                        this.parent.setProperties({ dataSourceSettings: { subTotalsPosition: 'Bottom' } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'sub-none-position'):
                        this.parent.setProperties({ dataSourceSettings: { subTotalsPosition: 'Auto' } }, true);
                        this.parent.refreshData();
                        break;
                    case (this.parent.element.id + 'numberFormattingMenu'):
                        if (this.parent.numberFormattingModule) {
                            this.parent.numberFormattingModule.showNumberFormattingDialog();
                        }
                        break;
                    case (this.parent.element.id + 'conditionalFormattingMenu'):
                        if (this.parent.conditionalFormattingModule) {
                            this.parent.conditionalFormattingModule.showConditionalFormattingDialog();
                        }
                        break;
                    case (this.parent.element.id + '_' + type):
                        Eif (args.item && args.item.text) {
                            Iif (type === 'ChartMoreOption') {
                                this.createChartTypeDialog();
                            }
                            else Iif (type === 'multipleAxes') {
                                if (this.parent.chartSettings.enableScrollOnMultiAxis) {
                                    this.isMultiAxisChange = true;
                                }
                                this.parent.chartSettings.enableMultipleAxis = !this.parent.chartSettings.enableMultipleAxis;
                                this.updateChartType(this.parent.chartSettings.chartSeries.type, true);
                            }
                            else Eif (this.getAllChartItems().indexOf(type) > -1) {
                                this.updateChartType(type, false);
                            }
                            else if (type === 'showLegend') {
                                this.parent.chart.legendSettings.visible = !this.showLableState;
                                if (this.parent.chartSettings.legendSettings) {
                                    this.parent.chartSettings.legendSettings.visible = !this.showLableState;
                                }
                                else {
                                    this.parent.setProperties({ chartSettings: { legendSettings: { visible: !this.showLableState } } }, true);
                                }
                                this.updateChartType(this.parent.chartSettings.chartSeries.type, true);
                            }
                        }
                        break;
                }
            }
            catch (execption) {
                this.parent.actionFailureMethod(execption);
            }
        };
        Toolbar.prototype.addEventListener = function () {
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.initToolbar, this.createToolbar, this);
        };
        Toolbar.prototype.getValidChartType = function () {
            var menuItems = [];
            for (var i = 0; (i <= this.parent.chartTypes.length); i++) {
                var type = this.parent.chartTypes[i];
                if ((this.getAllChartItems().indexOf(type) > -1) && (menuItems.indexOf(type) < 0)) {
                    menuItems.push(type);
                }
            }
            return menuItems;
        };
        Toolbar.prototype.createChartTypeDialog = function () {
            var _this_1 = this;
            var chartDialog = this.parent.element.appendChild(ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_ChartTypeDialog',
                className: cls.PIVOTCHART_TYPE_DIALOG
            }));
            var chartTypesDialog = new ej2_popups_1.Dialog({
                animationSettings: { effect: 'Fade' },
                allowDragging: true,
                header: this.parent.localeObj.getConstant('chartTypeSettings'),
                content: this.getDialogContent(),
                isModal: true,
                beforeOpen: this.beforeOpen.bind(this),
                visible: true,
                showCloseIcon: true,
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                width: 'auto',
                height: 'auto',
                position: { X: 'center', Y: 'center' },
                buttons: [
                    {
                        click: function () { _this_1.chartTypeDialogUpdate(); },
                        isFlat: false,
                        buttonModel: { cssClass: cls.OK_BUTTON_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), content: this.parent.localeObj.getConstant('ok'), isPrimary: true }
                    },
                    {
                        click: function () { _this_1.removeDialog(); },
                        isFlat: false,
                        buttonModel: { cssClass: cls.CANCEL_BUTTON_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), content: this.parent.localeObj.getConstant('cancel') }
                    }
                ],
                closeOnEscape: true,
                target: this.parent.element,
                cssClass: this.parent.cssClass,
                close: this.removeDialog.bind(this)
            });
            chartTypesDialog.isStringTemplate = true;
            chartTypesDialog.appendTo(chartDialog);
        };
        Toolbar.prototype.removeDialog = function () {
            var chartTypesDialog = ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeDialog', this.parent.element) ?
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeDialog', this.parent.element), ej2_popups_1.Dialog) : null;
            if (chartTypesDialog && !chartTypesDialog.isDestroyed) {
                chartTypesDialog.destroy();
            }
            if (document.getElementById(this.parent.element.id + '_ChartTypeDialog')) {
                ej2_base_1.remove(document.getElementById(this.parent.element.id + '_ChartTypeDialog'));
            }
        };
        Toolbar.prototype.chartTypeDialogUpdate = function () {
            var chartType = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeOption'), ej2_dropdowns_1.DropDownList).value;
            var checked = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DialogMultipleAxis'), ej2_buttons_1.CheckBox).checked;
            var checkedShow = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DialogShowLabel'), ej2_buttons_1.CheckBox).checked;
            this.parent.chart.legendSettings.visible = checkedShow;
            if (this.chartLableState) {
                this.parent.chart.legendSettings.visible = checkedShow;
                if (this.parent.chartSettings.legendSettings) {
                    this.parent.chartSettings.legendSettings.visible = checkedShow;
                }
                else {
                    this.parent.setProperties({ chartSettings: { legendSettings: { visible: checkedShow } } }, true);
                }
            }
            this.updateChartType(chartType, false);
            this.parent.chartSettings.enableMultipleAxis = checked;
            this.parent.chartSettings.multipleAxisMode = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_AxisModeOption'), ej2_dropdowns_1.DropDownList).value;
            var chartTypesDialog = ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeDialog', document) ?
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeDialog', document), ej2_popups_1.Dialog) : null;
            chartTypesDialog.close();
        };
        Toolbar.prototype.updateChartType = function (type, isMultiAxis) {
            Eif (this.getAllChartItems().indexOf(type) > -1) {
                Eif (this.parent.chart) {
                    this.parent.currentView = 'Chart';
                    this.parent.setProperties({ displayOption: { primary: 'Chart' } }, true);
                    if (this.parent.chartSettings.enableScrollOnMultiAxis && this.parent.chartSettings.enableMultipleAxis) {
                        this.parent.element.querySelector('.' + cls.PIVOTCHART).style.width = ej2_base_1.formatUnit(this.parent.grid ? this.parent.getGridWidthAsNumber() : this.parent.getWidthAsNumber());
                        this.parent.element.querySelector('.' + cls.PIVOTCHART).style.height = ej2_base_1.formatUnit(this.parent.pivotChartModule.getChartHeight());
                    }
                    this.parent.chart.setProperties({
                        width: ej2_base_1.formatUnit(this.parent.grid ? this.parent.getGridWidthAsNumber() : this.parent.getWidthAsNumber()),
                        height: ej2_base_1.formatUnit(this.parent.pivotChartModule.getChartHeight())
                    }, true);
                    if (this.parent.chartSettings.chartSeries.type === type && !isMultiAxis) {
                        this.parent.chart.refresh();
                    }
                    else {
                        this.parent.chartSettings.chartSeries.type = type;
                    }
                    var actionInfo = {
                        toolbarInfo: {
                            displayOption: this.parent.displayOption,
                            chartSettings: this.parent.chartSettings
                        }
                    };
                    this.parent.actionObj.actionInfo = actionInfo;
                }
            }
        };
        Toolbar.prototype.getDialogContent = function () {
            var mainWrapper = ej2_base_1.createElement('div', { className: 'e-chart-type-div-content' });
            var optionWrapperDiv = ej2_base_1.createElement('div', { className: 'e-chart-type-option-container' });
            var axisModeWrapperDiv = ej2_base_1.createElement('div', { className: 'e-multiple-axes-mode-container' });
            var optionTextDiv = ej2_base_1.createElement('div', {
                className: 'e-chart-type-option-text'
            });
            optionTextDiv.innerText = this.parent.localeObj.getConstant('ChartType');
            var axisModeTextDiv = ej2_base_1.createElement('div', {
                className: 'e-multiple-axes-mode-text'
            });
            axisModeTextDiv.innerText = this.parent.localeObj.getConstant('multipleAxisMode');
            var dropOptionDiv = ej2_base_1.createElement('div', { id: this.parent.element.id + '_ChartTypeOption' });
            var dropModeOptionDiv = ej2_base_1.createElement('div', { id: this.parent.element.id + '_AxisModeOption' });
            optionWrapperDiv.appendChild(optionTextDiv);
            optionWrapperDiv.appendChild(dropOptionDiv);
            var chartTypeDatasource = [];
            var multipleAxisModeDatasource = [
                { value: 'Stacked', text: this.parent.localeObj.getConstant('stacked') },
                { value: 'Single', text: this.parent.localeObj.getConstant('single') },
                { value: 'Combined', text: this.parent.localeObj.getConstant('combined') }
            ];
            var chartType = this.getValidChartType();
            for (var i = 0; i < chartType.length; i++) {
                chartTypeDatasource.push({
                    value: chartType[i], text: this.parent.localeObj.getConstant(chartType[i].toLowerCase())
                });
            }
            var optionWrapper = new ej2_dropdowns_1.DropDownList({
                dataSource: chartTypeDatasource, enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                fields: { value: 'value', text: 'text' },
                value: this.parent.chartSettings.chartSeries.type ? this.parent.chartSettings.chartSeries.type : this.getValidChartType()[0],
                width: '100%',
                change: this.changeDropDown.bind(this),
                cssClass: this.parent.cssClass
            });
            optionWrapper.isStringTemplate = true;
            optionWrapper.appendTo(dropOptionDiv);
            mainWrapper.appendChild(optionWrapperDiv);
            var checkboxWrap = ej2_base_1.createElement('input', {
                id: this.parent.element.id + '_DialogMultipleAxis',
                attrs: { 'type': 'checkbox' }
            });
            mainWrapper.appendChild(checkboxWrap);
            var labelCheckboxWrap = ej2_base_1.createElement('input', {
                id: this.parent.element.id + '_DialogShowLabel',
                attrs: { 'type': 'checkbox' }
            });
            mainWrapper.appendChild(labelCheckboxWrap);
            axisModeWrapperDiv.appendChild(axisModeTextDiv);
            axisModeWrapperDiv.appendChild(dropModeOptionDiv);
            mainWrapper.appendChild(axisModeWrapperDiv);
            var axisModeWrapper = new ej2_dropdowns_1.DropDownList({
                dataSource: multipleAxisModeDatasource, enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                fields: { value: 'value', text: 'text' },
                value: this.parent.chartSettings.multipleAxisMode ? this.parent.chartSettings.multipleAxisMode : 'Stacked',
                width: '100%',
                enabled: this.parent.chartSettings.enableMultipleAxis,
                cssClass: this.parent.cssClass
            });
            axisModeWrapper.isStringTemplate = true;
            axisModeWrapper.appendTo(dropModeOptionDiv);
            return mainWrapper;
        };
        Toolbar.prototype.changeDropDown = function (args) {
            var chartSettings = JSON.parse(this.parent.getChartSettings()).chartSettings;
            if (!(chartSettings && chartSettings.legendSettings && chartSettings.legendSettings.visible !== undefined)) {
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DialogShowLabel'), ej2_buttons_1.CheckBox).checked = true;
            }
            if (['Pie', 'Funnel', 'Pyramid', 'Doughnut', 'Pareto'].indexOf(args.value.toString()) > -1) {
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DialogMultipleAxis'), ej2_buttons_1.CheckBox).disabled = true;
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_AxisModeOption'), ej2_dropdowns_1.DropDownList).enabled = false;
            }
            else {
                var multipleAxisCheckBox = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DialogMultipleAxis'), ej2_buttons_1.CheckBox);
                multipleAxisCheckBox.disabled = false;
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_AxisModeOption'), ej2_dropdowns_1.DropDownList).enabled = multipleAxisCheckBox.checked;
            }
        };
        Toolbar.prototype.beforeOpen = function () {
            var _this_1 = this;
            var checkbox = new ej2_buttons_1.CheckBox({
                label: this.parent.localeObj.getConstant('multipleAxes'),
                cssClass: 'e-dialog-multiple-axis' + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                checked: this.parent.chartSettings.enableMultipleAxis ? this.parent.chartSettings.enableMultipleAxis : false,
                change: function (args) {
                    ej2_base_1.getInstance(ej2_base_1.select('#' + _this_1.parent.element.id + '_AxisModeOption'), ej2_dropdowns_1.DropDownList).enabled = args.checked;
                },
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer
            });
            var checkbox1 = new ej2_buttons_1.CheckBox({
                label: this.parent.localeObj.getConstant('showLegend'),
                checked: this.getLableState(),
                change: function () { _this_1.chartLableState = true; },
                cssClass: 'e-dialog-show-legend' + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer
            });
            var chartTypesDialog = ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeDialog', document) ?
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeDialog', document), ej2_popups_1.Dialog) : null;
            checkbox1.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_DialogShowLabel', chartTypesDialog.element));
            checkbox.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_DialogMultipleAxis', chartTypesDialog.element));
            if (['Pie', 'Funnel', 'Pyramid', 'Doughnut', 'Pareto'].indexOf(this.parent.chartSettings.chartSeries.type) > -1) {
                checkbox.disabled = true;
                ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_AxisModeOption'), ej2_dropdowns_1.DropDownList).enabled = false;
            }
            var chartSettings = JSON.parse(this.parent.getChartSettings()).chartSettings;
            if (chartSettings && chartSettings.legendSettings && chartSettings.legendSettings.visible !== undefined) {
                this.chartLableState = true;
            }
            else {
                this.chartLableState = false;
            }
        };
        Toolbar.prototype.refreshToolbar = function () {
            this.destroy();
            this.createToolbar();
        };
        Toolbar.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off(events.initToolbar, this.createToolbar);
        };
        Toolbar.prototype.destroy = function () {
            this.removeEventListener();
            var element = ej2_base_1.select('#' + this.parent.element.id + '_ConfirmDialog', document);
            var confirmPopUp = element ? ej2_base_1.getInstance(element, ej2_popups_1.Dialog) : null;
            if (confirmPopUp && !confirmPopUp.isDestroyed) {
                confirmPopUp.destroy();
                confirmPopUp = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'report-dialog', document);
            var dialog = element ? ej2_base_1.getInstance(element, ej2_popups_1.Dialog) : null;
            if (dialog && !dialog.isDestroyed) {
                dialog.destroy();
                dialog = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'mdx-dialog', document);
            var mdxDialog = element ? ej2_base_1.getInstance(element, ej2_popups_1.Dialog) : null;
            Iif (mdxDialog && !mdxDialog.isDestroyed) {
                mdxDialog.destroy();
                mdxDialog = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'chart_menu', document);
            var chartMenu = element ? ej2_base_1.getInstance(element, ej2_navigations_1.Menu) : null;
            if (chartMenu && !chartMenu.isDestroyed) {
                chartMenu.destroy();
                chartMenu = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + '_ChartTypeDialog', document);
            var chartTypesDialog = element ? ej2_base_1.getInstance(element, ej2_popups_1.Dialog) : null;
            Iif (chartTypesDialog && !chartTypesDialog.isDestroyed) {
                chartTypesDialog.destroy();
                chartTypesDialog = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'export_menu', document);
            var exportMenu = element ? ej2_base_1.getInstance(element, ej2_navigations_1.Menu) : null;
            if (exportMenu && !exportMenu.isDestroyed) {
                exportMenu.destroy();
                exportMenu = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'subtotal_menu', document);
            var subTotalMenu = element ? ej2_base_1.getInstance(element, ej2_navigations_1.Menu) : null;
            if (subTotalMenu && !subTotalMenu.isDestroyed) {
                subTotalMenu.destroy();
                subTotalMenu = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'grandtotal_menu', document);
            var grandTotalMenu = element ? ej2_base_1.getInstance(element, ej2_navigations_1.Menu) : null;
            if (grandTotalMenu && !grandTotalMenu.isDestroyed) {
                grandTotalMenu.destroy();
                grandTotalMenu = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'formatting_menu', document);
            var formattingMenu = element ? ej2_base_1.getInstance(element, ej2_navigations_1.Menu) : null;
            Iif (formattingMenu && !formattingMenu.isDestroyed) {
                formattingMenu.destroy();
                formattingMenu = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + '_reportlist', document);
            var reportList = element ? ej2_base_1.getInstance(element, ej2_dropdowns_1.DropDownList) : null;
            if (reportList && !reportList.isDestroyed) {
                reportList.destroy();
                reportList = null;
            }
            if (this.toolbar && !this.toolbar.isDestroyed) {
                this.toolbar.destroy();
                this.toolbar = null;
            }
            element = ej2_base_1.select('#' + this.parent.element.id + 'pivot-toolbar', document);
            if (element) {
                ej2_base_1.remove(element);
            }
        };
        Toolbar.prototype.focusToolBar = function () {
            ej2_base_1.removeClass(document.querySelector('.' + cls.GRID_TOOLBAR).querySelectorAll('.e-menu-item.e-focused'), 'e-focused');
            ej2_base_1.removeClass(document.querySelector('.' + cls.GRID_TOOLBAR).querySelectorAll('.e-menu-item.e-selected'), 'e-selected');
            Eif (document.querySelector('.e-toolbar-items')) {
                ej2_base_1.addClass([document.querySelector('.e-toolbar-items')], 'e-focused');
            }
        };
        return Toolbar;
    }());
    exports.Toolbar = Toolbar;
});