all files / pivotview/renderer/ render.js

75.14% Statements 934/1243
67.25% Branches 965/1435
84.15% Functions 69/82
75.14% Lines 934/1243
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 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126   138× 138× 138× 138× 138× 138× 138× 138× 138× 138× 138× 138× 138× 138× 138× 138× 138×   138× 138× 138× 138×   542× 542×   542×   542× 542× 542× 542× 542× 542× 542× 542× 542× 43× 43×     499× 149×   499×   542×           542× 542× 12×   542× 542×   359×   542×     541×   542× 542× 542× 542×     542× 530×                     542×   542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542× 542×   1956× 1956× 913× 913× 913× 913× 913× 913×         913× 913× 913×   913× 913×     913×   913×       906×       913×   913×     138× 138×                                                                                                                 137× 137×   559×           556×   556×     2364× 2364×                 14× 14×   14× 14×   32×         32× 32×         30× 30×   125551×   26467×   50×   382×   750×   33×                               695× 562×   695× 695× 695× 695×   695× 148× 148× 148× 45×     695×   695×                   28× 28×   28×       18×   18× 18× 18× 18×       18×     18× 18×   18× 18× 18× 18× 18×                                                                                                                                                                                                                                                                                                                                                                                                               18× 18× 18×                                       10× 10× 10× 10× 10× 10× 10× 10× 10× 10×         10×                                                                                                                                                                                                 10× 10×         10× 10×   10×   10×   98476× 98476× 98476× 98476× 98476× 227414× 227414× 227136× 227136× 227136× 10811×   227136× 9306×       278×     88892×   18× 18×       18× 18×         18× 18× 36×           18×                       693× 693× 158×   693× 193×   693× 693× 154×     13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13×         13×   124× 124× 676× 676× 89×         13×   23754× 23754× 23754× 3833×         3833× 3833×       34×               23754×                                                                                                                                                 122× 122×   76× 76×   76× 965× 965× 965× 965× 965× 965× 909×               56× 39×                 17×                   76×   125551× 125551× 125279× 125279× 125279×   125279× 125279× 125279× 10662× 9163× 9163× 9163× 9163×   9163×   9163× 9163×                                 9163× 11389× 2226×       11389×   9163× 9163× 9163× 1577×       9163× 9163×   9150× 518× 798× 798× 798× 518× 518×         8632×     9150×       1499×   10662× 10662× 932× 406× 406× 406× 406×         526×   60× 60×     466×       466×     10662× 10662× 1754×               10662×       10662× 10662× 2953×     18×                       114617× 114617× 114617× 114617× 114617× 114617× 114617× 42380×   114617×   114617× 18977×   95640× 10793×   114617× 10222×   114617×           114617×       125279× 136×   125279× 125279×   125551× 125551×   480×   480× 480×                     480×       480×         1499× 1499× 1499× 1382× 1382× 1382×     1382× 1382×   1382× 1396×   1382×     1382× 1382× 1382× 1382× 1396× 1396× 1396× 1396× 1396× 1396×   1382× 1382× 14×     14×   1382× 14×       1382× 1382×       117× 117× 117×   117× 117× 117× 117×                   117× 33× 33× 33×   84× 81× 81×   81×   117× 33× 33×       33×   84× 81× 81×   81×   117× 102×   102×     117× 117× 117× 117× 117× 40× 40× 40×         40× 20×     20×   40×   117×           117×           117× 117×   1499× 1499×       1499×   1499×   26467× 23754× 23754× 23754× 23754× 23754× 23754× 51895× 51895× 13883× 13883×     23754× 483×   23271× 443× 443× 443× 98×     23754× 23754× 23754× 23754× 20222×       8299×   8299×   20222× 1752×       3532×   23754×   23754× 3005× 3005× 1851×   1154× 1113×   3005× 3005×   3005×   3005× 528×     2477×     23754× 23754× 57× 25× 25×     32× 32× 32×       23754× 2445× 2445× 127× 127×   2445×             2445×       2445×   2445×     21309×   23754× 23754× 344×   23754× 23754× 51895× 13883× 1975×       1975× 75×     13883×   3041×     10842×       23754× 23754×     26467×   23754× 23754×     23754×       23754× 2445×   23754× 23754× 23754×   23754×   3532× 3532×   3532×         3532× 33×   3532×   33×   33× 33× 33× 13× 13× 13×   13×     33×                                     542× 542× 542× 1786× 526× 526×     542×   266× 266×   211× 211× 211× 211× 211× 211× 10122× 10122× 10122× 10122× 122926× 122848×     10122×                 55×   266×   205×       204×   2248×     2248× 2248× 2248×     2248× 2248× 2248× 2248× 966× 966× 966× 966× 966× 212×     2248× 2248×                             2804× 2804×   2804×       2804× 2804× 763×   2041× 302×   1739×             2804×   2072× 2072× 2072× 2072× 1936×       1936×     1936× 1917× 1917× 1917×   1917× 1917× 1917× 1917× 1917× 1098× 1098× 1098× 1098× 1098× 1098× 1098×   696×     402× 402×       819× 607×                 2072×   542× 542× 542× 542× 542×     542× 542×   516× 516× 516× 516×   516× 516× 1245× 1245× 1245× 1245× 1245× 1245× 1148× 7887×     7887× 7887×         7887× 7887× 4864× 4864×   4864×                             4864× 516× 516×     3023× 3023× 3023× 3023× 3023× 5921× 2898×     2898×     3023×                             3023×   5921× 5921× 5921×   3023×   7887× 7887×   7887× 7887× 7887× 7887×     1245×   516×                         26×   542× 176×   542× 542× 542×   29799×       29799×   29799×   175× 175× 175× 175× 175×   695× 695× 1356× 1356× 1356× 100×   86×     86× 86×       1256× 11×   1245× 22×   1256× 786× 1168× 1168× 391× 391×     777×         1356×   695×                                                     50×     50×       50× 50×   33×   33×       33×   750× 750× 50× 50× 50× 50×       50× 50×   50×   50×   50× 50× 50×     700× 700×   700×       700× 700×       700×       750× 750×       750× 750× 700×       700×     382× 382× 27× 27× 27× 27×       27× 27×   27×   27×   27× 27× 27×     381×   50× 50×         50× 50× 48× 48× 48× 48×   42×     48×       50× 46×   50×   511× 511× 6524× 6524× 6524× 6524× 71908× 71908×   71908×       511×   79795× 78647× 78647× 78647× 78647× 1047156× 977293×   1047156×   78647×   1148×   1132× 1132×   1132×   149033× 604×     148429×     149033× 604×     148429×          
define(["require", "exports", "@syncfusion/ej2-grids", "@syncfusion/ej2-grids", "@syncfusion/ej2-grids", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../../common/base/css-constant", "../../common/base/constant", "../../common/popups/aggregate-menu", "../../base/util"], function (require, exports, ej2_grids_1, ej2_grids_2, ej2_grids_3, ej2_base_1, ej2_base_2, cls, events, aggregate_menu_1, util_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Render = (function () {
        function Render(parent) {
            this.isAutoFitEnabled = false;
            this.pivotColumns = [];
            this.indentCollection = {};
            this.colPos = 0;
            this.lastSpan = 0;
            this.lvlCollection = {};
            this.hierarchyCollection = {};
            this.lvlPosCollection = {};
            this.hierarchyPosCollection = {};
            this.position = 0;
            this.measurePos = 0;
            this.maxMeasurePos = 0;
            this.hierarchyCount = 0;
            this.actualText = '';
            this.drilledLevelInfo = {};
            this.parent = parent;
            this.resColWidth = (this.parent.showGroupingBar && this.parent.groupingBarModule) ? (this.parent.isAdaptive ? 180 : 250) :
                (this.parent.isAdaptive ? 140 : 200);
            this.engine = this.parent.dataType === 'olap' ? this.parent.olapEngineModule : this.parent.engineModule;
            this.gridSettings = this.parent.gridSettings;
            this.formatList = this.getFormatList();
            this.aggMenu = new aggregate_menu_1.AggregateMenu(this.parent);
        }
        Render.prototype.render = function (refreshRequired) {
            Eif (refreshRequired) {
                this.initProperties();
            }
            this.resColWidth = (this.parent.showGroupingBar && this.parent.groupingBarModule) ? (this.parent.isAdaptive ? 180 : 250) :
                (this.parent.isAdaptive ? 140 : 200);
            this.engine = this.parent.dataType === 'olap' ? this.parent.olapEngineModule : this.parent.engineModule;
            this.gridSettings = this.parent.gridSettings;
            this.formatList = this.getFormatList();
            this.parent.gridCellCollection = {};
            this.injectGridModules(this.parent);
            this.rowStartPos = this.getRowStartPos();
            Eif (this.parent.grid && this.parent.grid.element && this.parent.element.querySelector('.' + cls.GRID_CLASS)) {
                this.parent.notEmpty = true;
                if (!this.engine.isEngineUpdated) {
                    this.engine.headerContent = this.frameDataSource('header');
                    this.engine.valueContent = this.frameDataSource('value');
                }
                else {
                    if (this.parent.enableValueSorting && this.parent.dataType !== 'olap') {
                        this.engine.valueContent = this.frameDataSource('value');
                    }
                    this.engine.isEngineUpdated = false;
                }
                this.parent.grid.setProperties({
                    columns: this.frameStackedHeaders(), dataSource: ((this.parent.dataType === 'olap' && this.parent.dataSourceSettings.url !== '') ? true :
                        (this.parent.dataSourceSettings.dataSource && this.parent.engineModule.data.length > 0 &&
                            this.parent.dataSourceSettings.values.length > 0)) && !this.engine.isEmptyData ?
                        this.frameGridDataSource(this.engine.valueContent) : this.frameDataSource('value')
                }, true);
                this.parent.grid.notify('datasource-modified', {});
                if (this.parent.isScrolling) {
                    this.parent.resizeInfo = {};
                }
                this.parent.grid.refreshColumns();
                if (this.parent.showGroupingBar && this.parent.groupingBarModule &&
                    this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS)) {
                    this.parent.groupingBarModule.setGridRowWidth();
                }
                if (this.isAutoFitEnabled) {
                    this.addPivotAutoFitClass();
                }
                else {
                    this.removePivotAutoFitClass();
                }
                var e = this.parent.element.querySelector('.' + cls.GRID_CLASS);
                e.querySelector('colGroup').innerHTML = this.parent.grid.getHeaderContent().querySelector('colgroup').innerHTML;
                this.parent.grid.width = this.calculateGridWidth();
                Iif (!this.gridSettings.allowAutoResizing && this.parent.showGroupingBar && this.parent.groupingBarModule && this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS)) {
                    this.parent.groupingBarModule.refreshUI();
                }
                if (!this.parent.isScrolling) {
                    this.calculateGridHeight(true);
                }
            }
            else {
                this.parent.element.innerHTML = '';
                this.bindGrid(this.parent, (this.engine.isEmptyData ? true : false));
                var gridElement = ej2_base_1.createElement('div', { id: this.parent.element.id + '_grid' });
                this.parent.element.appendChild(gridElement);
                this.parent.grid.isStringTemplate = true;
                this.parent.grid.appendTo(gridElement);
            }
            this.parent.grid.on(ej2_grids_1.headerRefreshed, this.refreshHeader, this);
        };
        Render.prototype.initProperties = function () {
            this.rowStartPos = undefined;
            this.maxIndent = undefined;
            this.resColWidth = undefined;
            this.isOverflows = undefined;
            this.indentCollection = {};
            this.formatList = undefined;
            this.colPos = 0;
            this.colGrandPos = undefined;
            this.rowGrandPos = undefined;
            this.lastSpan = 0;
            this.field = undefined;
            this.fieldCaption = undefined;
            this.lvlCollection = {};
            this.hierarchyCollection = {};
            this.lvlPosCollection = {};
            this.hierarchyPosCollection = {};
            this.position = 0;
            this.measurePos = 0;
            this.maxMeasurePos = 0;
            this.hierarchyCount = 0;
            this.actualText = '';
            this.timeOutObj = undefined;
        };
        Render.prototype.refreshHeader = function () {
            var mCont = this.parent.element.querySelector('.' + cls.CONTENT_VIRTUALTABLE_DIV);
            if (this.parent.enableVirtualization && !ej2_base_1.isNullOrUndefined(mCont)) {
                var virtualTable = ej2_base_1.closest(mCont, '.' + cls.GRID_CONTENT).querySelector('.' + cls.VIRTUALTABLE_DIV);
                var mHdr = this.parent.element.querySelector('.' + cls.MOVABLEHEADER_DIV);
                var vtr = mCont.querySelector('.' + cls.VIRTUALTRACK_DIV);
                this.parent.virtualHeaderDiv = mHdr.querySelector('.' + cls.VIRTUALTRACK_DIV);
                Eif (mHdr.querySelector('.' + cls.VIRTUALTRACK_DIV)) {
                    ej2_base_1.remove(mHdr.querySelector('.' + cls.VIRTUALTRACK_DIV));
                }
                else {
                    this.parent.virtualHeaderDiv = ej2_base_1.createElement('div', { className: cls.VIRTUALTRACK_DIV });
                }
                mHdr.appendChild(this.parent.virtualHeaderDiv);
                Eif (vtr) {
                    ej2_base_1.setStyleAttribute(this.parent.virtualHeaderDiv, { height: 0, width: vtr.style.width });
                }
                Eif (mHdr.querySelector('.' + cls.TABLE)) {
                    ej2_base_1.setStyleAttribute(mHdr.querySelector('.' + cls.TABLE), {
                        transform: (mCont.querySelector('.' + cls.TABLE).style.transform).split(',')[0] + ',' + 0 + 'px)'
                    });
                    var freezedCellValue = parseInt(mHdr.querySelector('.' + cls.TABLE)
                        .style.transform.split('(')[1].split(',')[0].split('px')[0], 10);
                    if (this.parent.enableRtl) {
                        this.parent.element.querySelector('.' + cls.FREEZED_CELL).style.right
                            = Number(freezedCellValue) + 'px';
                    }
                    else {
                        this.parent.element.querySelector('.' + cls.FREEZED_CELL).style.left
                            = Number(-freezedCellValue) + 'px';
                    }
                }
                var ele = this.parent.isAdaptive ? mCont :
                    (virtualTable && (virtualTable.style.display !== 'none')) ? virtualTable : mCont.parentElement;
                mHdr.scrollLeft = ele.scrollLeft;
            }
        };
        Render.prototype.bindGrid = function (parent, isEmpty) {
            this.injectGridModules(parent);
            this.parent.grid = new ej2_grids_2.Grid({
                cssClass: this.parent.cssClass,
                frozenColumns: 1,
                frozenRows: 0,
                enableHover: false,
                dataSource: isEmpty ? this.frameEmptyData() : this.frameDataSource('value'),
                columns: isEmpty ? this.frameEmptyColumns() : this.frameStackedHeaders(),
                height: isEmpty ? 'auto' : this.calculateGridHeight(),
                width: isEmpty ? (this.gridSettings.allowAutoResizing ? this.parent.width : 400) : this.calculateGridWidth(),
                locale: parent.locale,
                enableRtl: parent.enableRtl,
                allowExcelExport: parent.allowExcelExport,
                allowPdfExport: parent.allowPdfExport,
                allowResizing: this.gridSettings.allowResizing,
                allowTextWrap: this.gridSettings.allowTextWrap,
                clipMode: this.gridSettings.clipMode,
                allowReordering: (this.parent.showGroupingBar ? false : this.gridSettings.allowReordering),
                allowSelection: this.gridSettings.allowSelection,
                contextMenuItems: this.gridSettings.contextMenuItems,
                selectedRowIndex: this.gridSettings.selectedRowIndex,
                selectionSettings: this.gridSettings.selectionSettings,
                textWrapSettings: this.gridSettings.textWrapSettings,
                printMode: this.gridSettings.printMode,
                rowHeight: this.gridSettings.rowHeight,
                gridLines: this.gridSettings.gridLines,
                contextMenuClick: this.contextMenuClick.bind(this),
                contextMenuOpen: this.contextMenuOpen.bind(this),
                beforeCopy: this.gridSettings.beforeCopy ? this.gridSettings.beforeCopy.bind(this.parent) : undefined,
                beforePrint: this.gridSettings.beforePrint ? this.gridSettings.beforePrint.bind(this.parent) : undefined,
                printComplete: this.gridSettings.printComplete ? this.gridSettings.printComplete.bind(this.parent) : undefined,
                rowSelecting: this.gridSettings.rowSelecting ? this.gridSettings.rowSelecting.bind(this.parent) : undefined,
                rowSelected: this.rowSelected.bind(this),
                rowDeselecting: this.gridSettings.rowDeselecting ? this.gridSettings.rowDeselecting.bind(this.parent) : undefined,
                rowDeselected: this.rowDeselected.bind(this),
                cellSelecting: this.gridSettings.cellSelecting ? this.gridSettings.cellSelecting.bind(this.parent) : undefined,
                cellSelected: this.cellSelected.bind(this),
                cellDeselecting: this.gridSettings.cellDeselecting ? this.gridSettings.cellDeselecting.bind(this.parent) : undefined,
                cellDeselected: this.cellDeselected.bind(this),
                resizeStart: this.gridSettings.resizeStart ? this.gridSettings.resizeStart.bind(this.parent) : undefined,
                columnDragStart: this.gridSettings.columnDragStart ? this.gridSettings.columnDragStart.bind(this) : undefined,
                columnDrag: this.gridSettings.columnDrag ? this.gridSettings.columnDrag.bind(this) : undefined,
                columnDrop: this.gridSettings.columnDrop ? this.gridSettings.columnDrop.bind(this) : undefined,
                beforeExcelExport: this.beforeExcelExport.bind(this),
                resizing: this.setGroupWidth.bind(this),
                resizeStop: this.onResizeStop.bind(this),
                queryCellInfo: this.queryCellInfo.bind(this),
                dataBound: this.dataBound.bind(this),
                headerCellInfo: this.headerCellInfo.bind(this),
                excelHeaderQueryCellInfo: this.excelHeaderQueryCellInfo.bind(this),
                pdfHeaderQueryCellInfo: this.pdfHeaderQueryCellInfo.bind(this),
                excelQueryCellInfo: this.excelQueryCellInfo.bind(this),
                pdfQueryCellInfo: this.pdfQueryCellInfo.bind(this),
                beforePdfExport: this.gridSettings.beforePdfExport ? this.gridSettings.beforePdfExport.bind(this) : undefined,
                pdfExportComplete: this.pdfExportComplete.bind(this),
                excelExportComplete: this.excelExportComplete.bind(this),
                actionComplete: this.actionComplete.bind(this)
            });
            this.parent.grid.on('header-refreshed', this.headerRefreshed.bind(this));
            this.parent.grid.on('export-DataBound', this.excelDataBound.bind(this));
        };
        Render.prototype.actionComplete = function (args) {
            if (args && args.requestType === 'refresh' && this.isAutoFitEnabled) {
                this.removePivotAutoFitClass();
            }
        };
        Render.prototype.addPivotAutoFitClass = function () {
            Eif (!document.body.classList.contains(cls.PIVOT_VIEW_CLASS)) {
                document.body.classList.add(cls.PIVOT_VIEW_CLASS);
            }
            Eif (!document.body.classList.contains(cls.PIVOT_VIEW_AUTOFIT)) {
                document.body.classList.add(cls.PIVOT_VIEW_AUTOFIT);
            }
        };
        Render.prototype.removePivotAutoFitClass = function () {
            if (document.body.classList.contains(cls.PIVOT_VIEW_CLASS)) {
                document.body.classList.remove(cls.PIVOT_VIEW_CLASS);
            }
            if (document.body.classList.contains(cls.PIVOT_VIEW_AUTOFIT)) {
                document.body.classList.remove(cls.PIVOT_VIEW_AUTOFIT);
            }
        };
        Render.prototype.headerRefreshed = function () {
            var mHdr = this.parent.element.querySelector('.' + cls.MOVABLEHEADER_DIV);
            Iif (this.parent.lastGridSettings && Object.keys(this.parent.lastGridSettings).indexOf('allowResizing') > -1 && !ej2_base_1.isNullOrUndefined(mHdr) && mHdr.querySelector('.' + cls.TABLE) &&
                this.parent.showGroupingBar && this.parent.groupingBarModule && this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS)) {
                this.parent.lastGridSettings = undefined;
                this.parent.groupingBarModule.setGridRowWidth();
            }
        };
        Render.prototype.beforeExcelExport = function (args) {
            Eif (!ej2_base_1.isNullOrUndefined(args.gridObject.columns) && !ej2_base_1.isNullOrUndefined(this.parent.pivotColumns)) {
                args.gridObject.columns[args.gridObject.columns.length - 1].width =
                    this.parent.pivotColumns[this.parent.pivotColumns.length - 1].width;
            }
            this.parent.trigger(events.beforeExcelExport, args);
        };
        Render.prototype.rowSelected = function (args) {
            this.parent.renderModule.selected();
            this.parent.trigger(events.rowSelected, args);
        };
        Render.prototype.rowDeselected = function (args) {
            this.parent.renderModule.selected();
            this.parent.trigger(events.rowDeselected, args);
        };
        Render.prototype.cellSelected = function (args) {
            Iif (this.parent.rowRangeSelection.enable) {
                this.parent.grid.selectionModule.selectRowsByRange(this.parent.rowRangeSelection.startIndex, this.parent.rowRangeSelection.endIndex);
                this.parent.rowRangeSelection.enable = false;
            }
            else {
                this.parent.renderModule.selected();
                this.parent.trigger(events.selected, args);
            }
        };
        Render.prototype.cellSelecting = function (args) {
            this.parent.trigger(events.cellSelecting, args);
        };
        Render.prototype.cellDeselected = function (args) {
            this.parent.renderModule.selected();
            this.parent.trigger(events.cellDeselected, args);
        };
        Render.prototype.queryCellInfo = function (args) {
            this.parent.renderModule.rowCellBoundEvent(args);
        };
        Render.prototype.headerCellInfo = function (args) {
            this.parent.renderModule.columnCellBoundEvent(args);
        };
        Render.prototype.excelHeaderQueryCellInfo = function (args) {
            this.parent.renderModule.excelColumnEvent(args);
        };
        Render.prototype.pdfQueryCellInfo = function (args) {
            this.parent.renderModule.pdfRowEvent(args);
        };
        Render.prototype.excelQueryCellInfo = function (args) {
            this.parent.renderModule.excelRowEvent(args);
        };
        Render.prototype.pdfHeaderQueryCellInfo = function (args) {
            this.parent.renderModule.pdfColumnEvent(args);
        };
        Render.prototype.pdfExportComplete = function (args) {
            Iif (this.parent.lastColumn !== undefined && this.parent.lastColumn.width !== 'auto') {
                this.parent.lastColumn.width = 'auto';
                this.parent.lastColumn = undefined;
            }
            var exportCompleteEventArgs = {
                type: 'PDF',
                promise: args.promise
            };
            this.parent.trigger(events.exportComplete, exportCompleteEventArgs);
        };
        Render.prototype.excelExportComplete = function (args) {
            Iif (this.parent.lastColumn !== undefined && this.parent.lastColumn.width !== 'auto') {
                this.parent.lastColumn.width = 'auto';
                this.parent.lastColumn = undefined;
            }
            var exportCompleteEventArgs = {
                type: 'Excel/CSV',
                promise: args.promise
            };
            this.parent.trigger(events.exportComplete, exportCompleteEventArgs);
        };
        Render.prototype.dataBound = function () {
            if (this.parent.notEmpty) {
                this.calculateGridHeight(true);
            }
            this.parent.isScrolling = false;
            this.setFocusOnLastCell();
            Eif (!ej2_base_1.isNullOrUndefined(this.parent['renderReactTemplates'])) {
                this.parent['renderReactTemplates']();
            }
            if (this.parent.isInitial) {
                this.parent.isInitial = false;
                this.parent.refreshData();
                if (this.parent.enableVirtualization) {
                    this.parent.onContentReady();
                }
            }
            this.parent.notify(events.contentReady, {});
        };
        Render.prototype.setFocusOnLastCell = function () {
            Iif (this.parent.keyboardModule && this.parent.keyboardModule.event &&
                this.parent.keyboardModule.event.target.nodeName === 'TD') {
                var gridFocus = this.parent.grid.serviceLocator.getService('focus');
                gridFocus.setFocusedElement(this.parent.keyboardModule.event.target);
                gridFocus.focus(this.parent.keyboardModule.event);
                ej2_base_2.addClass([this.parent.keyboardModule.event.target], ['e-focused', 'e-focus']);
                this.parent.keyboardModule.event.target.setAttribute('tabindex', '0');
                this.parent.keyboardModule.event = undefined;
            }
        };
        Render.prototype.getCellElement = function (target) {
            var currentElement = ej2_base_1.closest(target, 'td');
            if (ej2_base_1.isNullOrUndefined(currentElement)) {
                currentElement = ej2_base_1.closest(target, 'th');
            }
            return currentElement;
        };
        Render.prototype.contextMenuOpen = function (args) {
            var _this = this;
            Iif (args.element && this.parent.cssClass) {
                ej2_base_2.addClass([args.element.parentElement], this.parent.cssClass);
            }
            var _loop_1 = function (item) {
                var cellTarget = this_1.parent.lastCellClicked ? this_1.parent.lastCellClicked :
                    (this_1.parent.isAdaptive ? args.event.target : this_1.parent.lastCellClicked);
                var elem = this_1.getCellElement(cellTarget);
                var bool = void 0;
                var isGroupElement = void 0;
                Iif (!elem || (elem && Number(elem.getAttribute('index')) === 0 && Number(elem.getAttribute('data-colindex')) === 0)) {
                    args.cancel = true;
                    return { value: void 0 };
                }
                Iif (elem.classList.contains('e-valuesheader') || elem.classList.contains('e-stot')) {
                    bool = true;
                }
                Eif (this_1.parent.allowGrouping && this_1.parent.groupingModule && !this_1.validateField(elem)) {
                    isGroupElement = true;
                }
                var rowIndex = Number(elem.getAttribute('index'));
                var colIndex = Number(elem.getAttribute('data-colindex'));
                var pivotValue1 = this_1.parent.pivotValues[rowIndex][colIndex];
                var selectedID = item.id;
                switch (selectedID) {
                    case this_1.parent.element.id + '_expand':
                        if (elem.querySelectorAll('.' + cls.EXPAND).length > 0) {
                            if (ej2_base_2.selectAll('#' + this_1.parent.element.id + '_expand', args.element)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.add(cls.MENU_DISABLE);
                            }
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.contains(cls.MENU_DISABLE)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.remove(cls.MENU_DISABLE);
                            }
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.contains(cls.MENU_HIDE)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.remove(cls.MENU_HIDE);
                                ej2_base_2.select('#' + this_1.parent.element.id + '_collapse', args.element).classList.remove(cls.MENU_HIDE);
                            }
                        }
                        else {
                            if (bool) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.add(cls.MENU_HIDE);
                            }
                            else {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.add(cls.MENU_DISABLE);
                            }
                        }
                        break;
                    case this_1.parent.element.id + '_collapse':
                        if (elem.querySelectorAll('.' + cls.COLLAPSE).length > 0) {
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.add(cls.MENU_DISABLE);
                            }
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_collapse', args.element).classList.contains(cls.MENU_DISABLE)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_collapse', args.element).classList.remove(cls.MENU_DISABLE);
                            }
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_collapse', args.element).classList.contains(cls.MENU_HIDE)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_collapse', args.element).classList.remove(cls.MENU_HIDE);
                                ej2_base_2.select('#' + this_1.parent.element.id + '_expand', args.element).classList.remove(cls.MENU_HIDE);
                            }
                        }
                        else {
                            if (bool) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_collapse', args.element).classList.add(cls.MENU_HIDE);
                            }
                            else {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_collapse', args.element).classList.add(cls.MENU_DISABLE);
                            }
                        }
                        break;
                    case this_1.parent.element.id + '_custom_group':
                        Iif (!isGroupElement && args.items.length === 2) {
                            args.cancel = true;
                        }
                        Eif (ej2_base_2.selectAll('#' + this_1.parent.element.id + '_custom_group', args.element)) {
                            ej2_base_2.addClass([ej2_base_2.select('#' + this_1.parent.element.id + '_custom_group', args.element)], cls.MENU_HIDE);
                        }
                        Eif (isGroupElement) {
                            Eif (ej2_base_2.selectAll('#' + this_1.parent.element.id + '_custom_group', args.element)) {
                                ej2_base_2.removeClass([ej2_base_2.select('#' + this_1.parent.element.id + '_custom_group', args.element)], cls.MENU_HIDE);
                            }
                        }
                        break;
                    case this_1.parent.element.id + '_custom_ungroup':
                        Eif (ej2_base_2.selectAll('#' + this_1.parent.element.id + '_custom_ungroup', args.element)) {
                            ej2_base_2.addClass([ej2_base_2.select('#' + this_1.parent.element.id + '_custom_ungroup', args.element)], cls.MENU_HIDE);
                        }
                        Eif (isGroupElement) {
                            var isUngroupOption = false;
                            var fieldName = elem.getAttribute('fieldname');
                            var groupField = util_1.PivotUtil.getFieldByName(fieldName, this_1.parent.dataSourceSettings.groupSettings);
                            if (groupField && groupField.type === 'Custom' || (this_1.parent.engineModule.fieldList[fieldName].isCustomField && fieldName.indexOf('_custom_group') > -1)) {
                                groupField = util_1.PivotUtil.getFieldByName(fieldName.replace('_custom_group', ''), this_1.parent.dataSourceSettings.groupSettings);
                                Eif (groupField) {
                                    var cell = this_1.parent.engineModule.pivotValues[Number(elem.getAttribute('index'))][Number(elem.getAttribute('data-colindex'))];
                                    var selectedCellsInfo = this_1.parent.groupingModule.getSelectedCells(cell.axis, fieldName, cell.actualText.toString());
                                    selectedCellsInfo.push({ axis: cell.axis, fieldName: fieldName, name: cell.actualText.toString(),
                                        cellInfo: cell });
                                    var selectedOptions = this_1.parent.groupingModule.getSelectedOptions(selectedCellsInfo);
                                    for (var _i = 0, _a = groupField.customGroups; _i < _a.length; _i++) {
                                        var customGroup = _a[_i];
                                        if (selectedOptions.indexOf(customGroup.groupName) > -1) {
                                            isUngroupOption = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            else if (groupField && (groupField.type === 'Date' || groupField.type === 'Number') ||
                                (this_1.parent.engineModule.fieldList[fieldName].isCustomField && fieldName.indexOf('_date_group') > -1)) {
                                isUngroupOption = true;
                            }
                            if (ej2_base_2.selectAll('#' + this_1.parent.element.id + '_custom_ungroup', args.element) && isUngroupOption) {
                                ej2_base_2.removeClass([ej2_base_2.select('#' + this_1.parent.element.id + '_custom_ungroup', args.element)], cls.MENU_HIDE);
                            }
                        }
                        break;
                    case this_1.parent.element.id + '_drillthrough':
                        if (!this_1.parent.allowDrillThrough) {
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_drillthrough', args.element)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_drillthrough', args.element).classList.add(cls.MENU_DISABLE);
                            }
                        }
                        else if (!(elem.classList.contains('e-summary'))) {
                            if (elem.innerText === '') {
                                if (ej2_base_2.select('#' + this_1.parent.element.id + '_drillthrough', args.element)) {
                                    ej2_base_2.select('#' + this_1.parent.element.id + '_drillthrough', args.element).classList.add(cls.MENU_DISABLE);
                                }
                            }
                        }
                        else {
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_drillthrough', args.element).classList.contains(cls.MENU_DISABLE)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_drillthrough', args.element).classList.remove(cls.MENU_DISABLE);
                            }
                        }
                        break;
                    case this_1.parent.element.id + '_sortasc':
                        if (!this_1.parent.enableValueSorting) {
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element).classList.add(cls.MENU_DISABLE);
                            }
                        }
                        else if (elem.querySelectorAll('.e-icon-descending').length > 0) {
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element).classList.add(cls.MENU_DISABLE);
                            }
                            else {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element).classList.remove(cls.MENU_DISABLE);
                            }
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element).classList.contains(cls.MENU_DISABLE)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element).classList.remove(cls.MENU_DISABLE);
                            }
                        }
                        else if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element).classList.contains(cls.MENU_DISABLE)) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element).classList.remove(cls.MENU_DISABLE);
                        }
                        break;
                    case this_1.parent.element.id + '_sortdesc':
                        if (!this_1.parent.enableValueSorting) {
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element).classList.add(cls.MENU_DISABLE);
                            }
                        }
                        else if (elem.querySelectorAll('.e-icon-ascending').length > 0) {
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element).classList.add(cls.MENU_DISABLE);
                            }
                            else {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element).classList.remove(cls.MENU_DISABLE);
                            }
                            if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element).classList.contains(cls.MENU_DISABLE)) {
                                ej2_base_2.select('#' + this_1.parent.element.id + '_sortdesc', args.element).classList.remove(cls.MENU_DISABLE);
                            }
                        }
                        else if (ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element).classList.contains(cls.MENU_DISABLE)) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_sortasc', args.element).classList.remove(cls.MENU_DISABLE);
                        }
                        break;
                    case this_1.parent.element.id + '_CalculatedField':
                        if (!this_1.parent.allowCalculatedField) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_CalculatedField', args.element).classList.add(cls.MENU_DISABLE);
                        }
                        break;
                    case this_1.parent.element.id + '_pdf':
                        if (!this_1.parent.allowPdfExport) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_pdf', args.element).classList.add(cls.MENU_DISABLE);
                        }
                        break;
                    case this_1.parent.element.id + '_excel':
                        if (!this_1.parent.allowExcelExport) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_excel', args.element).classList.add(cls.MENU_DISABLE);
                        }
                        break;
                    case this_1.parent.element.id + '_csv':
                        if (!this_1.parent.allowExcelExport) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_csv', args.element).classList.add(cls.MENU_DISABLE);
                        }
                        break;
                    case this_1.parent.element.id + '_exporting':
                        if ((!this_1.parent.allowExcelExport) && (!this_1.parent.allowPdfExport)) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_exporting', args.element).classList.add(cls.MENU_DISABLE);
                        }
                        break;
                    case this_1.parent.element.id + '_aggregate':
                        if ((ej2_base_2.select('#' + this_1.parent.element.id + '_aggregate', args.element)) &&
                            (!ej2_base_2.select('#' + this_1.parent.element.id + '_aggregate', args.element).classList.contains(cls.MENU_DISABLE))) {
                            ej2_base_2.select('#' + this_1.parent.element.id + '_aggregate', args.element).classList.add(cls.MENU_DISABLE);
                        }
                        if ((elem.classList.contains('e-valuesheader') || elem.classList.contains('e-valuescontent') ||
                            (elem.classList.contains('e-stot') && elem.classList.contains('e-rowsheader'))) && this_1.parent.dataType !== 'olap') {
                            var fieldType_1;
                            if (!(elem.innerText === '')) {
                                fieldType_1 = this_1.parent.engineModule.fieldList[pivotValue1.actualText.toString()].type;
                            }
                            var eventArgs = {
                                cancel: false, fieldName: pivotValue1.actualText.toString(),
                                aggregateTypes: this_1.getMenuItem(fieldType_1).slice(),
                                displayMenuCount: 7
                            };
                            this_1.parent.trigger(events.aggregateMenuOpen, eventArgs, function (observedArgs) {
                                if (!observedArgs.cancel && !(elem.innerText === '')) {
                                    var menuItem = [];
                                    var checkDuplicates = [];
                                    for (var i = 0; i < observedArgs.aggregateTypes.length; i++) {
                                        var key = observedArgs.aggregateTypes[i];
                                        if (fieldType_1 !== 'number') {
                                            if ((['Count', 'DistinctCount'].indexOf(key) > -1) && (checkDuplicates.indexOf(key) < 0)) {
                                                menuItem.push({ text: _this.parent.localeObj.getConstant(key), id: _this.parent.element.id + '_Agg' + key });
                                                checkDuplicates.push(key);
                                            }
                                        }
                                        else {
                                            if ((_this.parent.getAllSummaryType().indexOf(key) > -1) && (checkDuplicates.indexOf(key) < 0)) {
                                                menuItem.push({ text: _this.parent.localeObj.getConstant(key), id: _this.parent.element.id + '_Agg' + key });
                                                checkDuplicates.push(key);
                                            }
                                        }
                                    }
                                    if (menuItem.length > observedArgs.displayMenuCount) {
                                        menuItem.splice(observedArgs.displayMenuCount);
                                        menuItem.push({
                                            text: _this.parent.localeObj.getConstant('MoreOption'),
                                            id: _this.parent.element.id + '_Agg' + 'MoreOption'
                                        });
                                    }
                                    if (menuItem && menuItem.length >= 1) {
                                        item.items = menuItem;
                                        ej2_base_2.select('#' + _this.parent.element.id + '_aggregate', args.element).classList.remove(cls.MENU_DISABLE);
                                    }
                                }
                            });
                        }
                        break;
                }
            };
            var this_1 = this;
            for (var _i = 0, _a = args.items; _i < _a.length; _i++) {
                var item = _a[_i];
                var state_1 = _loop_1(item);
                Iif (typeof state_1 === "object")
                    return state_1.value;
            }
            this.parent.trigger(events.contextMenuOpen, args);
        };
        Render.prototype.getMenuItem = function (isStringField) {
            var menuItems = [];
            for (var i = 0; i < this.parent.aggregateTypes.length; i++) {
                var key = this.parent.aggregateTypes[i];
                if (isStringField !== 'string') {
                    if ((this.parent.getAllSummaryType().indexOf(key) > -1) && (menuItems.indexOf(key) === -1)) {
                        menuItems.push(key);
                    }
                }
                else {
                    if ((['Count', 'DistinctCount'].indexOf(key) > -1) && (menuItems.indexOf(key) === -1)) {
                        menuItems.push(key);
                    }
                }
            }
            return menuItems;
        };
        Render.prototype.contextMenuClick = function (args) {
            var _this = this;
            var target = this.parent.lastCellClicked;
            var selected = args.item.id;
            var exportArgs = {};
            var ele = this.getCellElement(target);
            var rowIndx = Number(ele.getAttribute('index'));
            var colIndx = Number(ele.getAttribute('data-colindex'));
            var pivotValue = this.parent.pivotValues[rowIndx][colIndx];
            var aggregateType;
            Iif (args.item.id.indexOf(this.parent.element.id + '_Agg') > -1) {
                this.field = this.parent.engineModule.fieldList[pivotValue.actualText.toString()].id;
                this.fieldCaption = this.parent.engineModule.fieldList[pivotValue.actualText.toString()].caption;
                aggregateType = args.item.id.split('_Agg')[1];
            }
            switch (selected) {
                case this.parent.element.id + '_pdf':
                    exportArgs = {
                        pdfDoc: undefined,
                        isBlob: false,
                        isMultipleExport: false,
                        pdfExportProperties: { fileName: 'Export.pdf' }
                    };
                    this.parent.trigger(events.beforeExport, exportArgs, function (observedArgs) {
                        _this.parent.pdfExport(observedArgs.pdfExportProperties, observedArgs.isMultipleExport, observedArgs.pdfDoc, observedArgs.isBlob);
                    });
                    break;
                case this.parent.element.id + '_excel':
                    exportArgs = {
                        isBlob: false,
                        isMultipleExport: false,
                        workbook: undefined,
                        excelExportProperties: { fileName: 'Export.xlsx' }
                    };
                    this.parent.trigger(events.beforeExport, exportArgs, function (observedArgs) {
                        _this.parent.excelExport(observedArgs.excelExportProperties, observedArgs.isMultipleExport, observedArgs.workbook, observedArgs.isBlob);
                    });
                    break;
                case this.parent.element.id + '_csv':
                    exportArgs = {
                        isBlob: false,
                        workbook: undefined,
                        isMultipleExport: false,
                        excelExportProperties: { fileName: 'Export.csv' }
                    };
                    this.parent.trigger(events.beforeExport, exportArgs, function (observedArgs) {
                        _this.parent.csvExport(observedArgs.excelExportProperties, observedArgs.isMultipleExport, observedArgs.workbook, observedArgs.isBlob);
                    });
                    break;
                case this.parent.element.id + '_drillthrough_menu': {
                    var event_1 = new MouseEvent('dblclick', {
                        'view': window,
                        'bubbles': true,
                        'cancelable': true
                    });
                    ele.dispatchEvent(event_1);
                    break;
                }
                case this.parent.element.id + '_sortasc':
                    this.parent.setProperties({
                        dataSourceSettings: {
                            valueSortSettings: {
                                headerText: pivotValue.valueSort.levelName,
                                headerDelimiter: this.parent.dataSourceSettings.valueSortSettings.headerDelimiter
                            }
                        }
                    });
                    this.parent.dataSourceSettings.valueSortSettings.sortOrder = 'Ascending';
                    break;
                case this.parent.element.id + '_sortdesc':
                    this.parent.setProperties({
                        dataSourceSettings: {
                            valueSortSettings: {
                                headerText: pivotValue.valueSort.levelName,
                                headerDelimiter: this.parent.dataSourceSettings.valueSortSettings.headerDelimiter
                            }
                        }
                    });
                    this.parent.dataSourceSettings.valueSortSettings.sortOrder = 'Descending';
                    break;
                case this.parent.element.id + '_expand':
                    if (ele.querySelectorAll('.' + cls.EXPAND)) {
                        var exp = ele.querySelectorAll('.' + cls.EXPAND)[0];
                        this.parent.onDrill(exp);
                    }
                    break;
                case this.parent.element.id + '_collapse':
                    if (ele.querySelectorAll('.' + cls.COLLAPSE)) {
                        var colp = ele.querySelectorAll('.' + cls.COLLAPSE)[0];
                        this.parent.onDrill(colp);
                    }
                    break;
                case this.parent.element.id + '_CalculatedField':
                    this.parent.calculatedFieldModule.createCalculatedFieldDialog();
                    break;
                case this.parent.element.id + '_AggMoreOption':
                case this.parent.element.id + '_AggDifferenceFrom':
                case this.parent.element.id + '_AggPercentageOfDifferenceFrom':
                case this.parent.element.id + '_AggPercentageOfParentTotal':
                    ele.setAttribute('id', this.field);
                    ele.setAttribute('data-caption', this.fieldCaption);
                    ele.setAttribute('data-field', this.field);
                    ele.setAttribute('data-type', this.engine.fieldList[pivotValue.actualText.toString()].aggregateType);
                    ele.setAttribute('data-basefield', this.engine.fieldList[pivotValue.actualText.toString()].baseField);
                    ele.setAttribute('data-baseItem', this.engine.fieldList[pivotValue.actualText.toString()].baseItem);
                    this.aggMenu.createValueSettingsDialog(ele, this.parent.element, aggregateType);
                    break;
                case this.parent.element.id + '_Agg' + aggregateType:
                    this.updateAggregate(aggregateType);
                    break;
                case this.parent.element.id + '_custom_group':
                case this.parent.element.id + '_custom_ungroup':
                    Eif (this.parent.groupingModule) {
                        var args_1 = {
                            target: ele,
                            option: selected,
                            parentElement: this.parent.element
                        };
                        this.parent.notify(events.initGrouping, args_1);
                        this.parent.grid.contextMenuModule.contextMenu.close();
                    }
                    break;
            }
            this.parent.trigger(events.contextMenuClick, args);
        };
        Render.prototype.validateColumnTotalcell = function (columnIndex) {
            var headerPosKeys = Object.keys(this.engine.headerContent);
            var keysLength = headerPosKeys.length;
            var sumLock = false;
            var fieldName = '';
            for (var pos = keysLength - 1; pos >= 0; pos--) {
                var cell = this.engine.headerContent[Number(headerPosKeys[pos])][columnIndex];
                if (cell) {
                    sumLock = sumLock && fieldName !== '' ? fieldName === cell.valueSort.axis : false;
                    fieldName = cell.valueSort.axis ? cell.valueSort.axis.toString() : '';
                    if (cell.type === 'sum') {
                        sumLock = true;
                    }
                    if (sumLock && cell.members && cell.members.length > 0) {
                        return true;
                    }
                }
                else {
                    return false;
                }
            }
            return false;
        };
        Render.prototype.validateField = function (target) {
            var isValueField = false;
            Iif (target.classList.contains('e-stot') || target.classList.contains('e-gtot') || target.classList.contains('e-valuescontent') || target.classList.contains('e-valuesheader')) {
                isValueField = true;
            }
            else {
                var fieldName = target.getAttribute('fieldName');
                Iif (!fieldName || fieldName === '') {
                    var rowIndx = Number(target.getAttribute('index'));
                    var colIndx = Number(target.getAttribute('data-colindex'));
                    fieldName = this.engine.pivotValues[rowIndx][colIndx].actualText;
                }
                var valuefields = this.parent.dataSourceSettings.values;
                for (var valueCnt = 0; valueCnt < valuefields.length; valueCnt++) {
                    Iif (this.parent.dataSourceSettings.values[valueCnt].name === fieldName) {
                        isValueField = true;
                        break;
                    }
                }
            }
            return isValueField;
        };
        Render.prototype.updateAggregate = function (aggregate) {
            if (this.parent.getAllSummaryType().indexOf(aggregate) > -1) {
                var valuefields = this.parent.dataSourceSettings.values;
                for (var valueCnt = 0; valueCnt < this.parent.dataSourceSettings.values.length; valueCnt++) {
                    if (this.parent.dataSourceSettings.values[valueCnt].name === this.field) {
                        var dataSourceItem = valuefields[valueCnt];
                        dataSourceItem.type = aggregate;
                    }
                }
            }
        };
        Render.prototype.injectGridModules = function (parent) {
            ej2_grids_2.Grid.Inject(ej2_grids_2.Freeze);
            if (parent.allowExcelExport) {
                ej2_grids_2.Grid.Inject(ej2_grids_2.ExcelExport);
            }
            if (parent.allowPdfExport) {
                ej2_grids_2.Grid.Inject(ej2_grids_2.PdfExport);
            }
            ej2_grids_2.Grid.Inject(ej2_grids_3.Selection, ej2_grids_1.Reorder, ej2_grids_2.Resize);
            if (this.gridSettings.contextMenuItems) {
                ej2_grids_2.Grid.Inject(ej2_grids_2.ContextMenu);
            }
        };
        Render.prototype.updateGridSettings = function () {
            this.injectGridModules(this.parent);
            this.parent.grid.allowResizing = this.gridSettings.allowResizing;
            this.parent.grid.clipMode = this.gridSettings.clipMode;
            this.parent.grid.allowTextWrap = this.gridSettings.allowTextWrap;
            this.parent.grid.allowReordering = (this.parent.showGroupingBar ? false : this.gridSettings.allowReordering);
            this.parent.grid.allowSelection = this.gridSettings.allowSelection;
            this.parent.grid.contextMenuItems = this.gridSettings.contextMenuItems;
            this.parent.grid.selectedRowIndex = this.gridSettings.selectedRowIndex;
            this.parent.grid.selectionSettings = this.gridSettings.selectionSettings;
            this.parent.grid.textWrapSettings = this.gridSettings.textWrapSettings;
            this.parent.grid.printMode = this.gridSettings.printMode;
            this.parent.grid.rowHeight = this.gridSettings.rowHeight;
            this.parent.grid.gridLines = this.gridSettings.gridLines;
            if (this.parent.lastGridSettings) {
                var keys = Object.keys(this.parent.lastGridSettings);
                if (keys.indexOf('height') > -1) {
                    this.parent.grid.height = this.gridSettings.height;
                }
                if (keys.indexOf('width') > -1) {
                    this.parent.grid.width = this.gridSettings.width;
                }
                this.updatePivotColumns();
                if (keys.indexOf('allowTextWrap') > -1 || keys.indexOf('clipMode') > -1) {
                    this.parent.layoutRefresh();
                }
            }
            this.clearColumnSelection();
        };
        Render.prototype.updatePivotColumns = function () {
            var keys = Object.keys(this.parent.lastGridSettings);
            for (var colPos = 0; colPos < this.parent.pivotColumns.length; colPos++) {
                var pivotColumn = this.parent.pivotColumns[colPos];
                for (var keyPos = 0; keyPos < keys.length; keyPos++) {
                    var key = keys[keyPos];
                    if (!ej2_base_1.isNullOrUndefined((this.parent.pivotColumns[colPos])[key])) {
                        pivotColumn[key] = this.parent.lastGridSettings[key];
                    }
                }
            }
            this.parent.fillGridColumns(this.parent.grid.columns);
        };
        Render.prototype.clearColumnSelection = function () {
            ej2_base_2.removeClass(this.parent.element.querySelectorAll('.' + cls.CELL_ACTIVE_BGCOLOR), [cls.CELL_ACTIVE_BGCOLOR, cls.SELECTED_BGCOLOR]);
        };
        Render.prototype.appendValueSortIcon = function (cell, tCell, rCnt, cCnt, column) {
            var engine = this.parent.dataType === 'pivot' ? this.parent.engineModule : this.parent.olapEngineModule;
            var vSort = this.parent.dataSourceSettings.valueSortSettings;
            if (this.parent.enableValueSorting && vSort && vSort.headerText !== '') {
                var len = (cell.type === 'grand sum' &&
                    this.parent.dataSourceSettings.values.length === 1 && !this.parent.dataSourceSettings.alwaysShowValueHeader) ? 0 :
                    (this.parent.dataSourceSettings.values.length > 1 || this.parent.dataSourceSettings.alwaysShowValueHeader) ?
                        (engine.headerContent.length - 1) :
                        this.parent.dataSourceSettings.columns.length === 0 ? 0 : (engine.headerContent.length - 1);
                var lock = (vSort && vSort.headerText) ? cell.valueSort.levelName === vSort.headerText : cCnt === vSort.columnIndex;
                if (vSort !== undefined && lock && (rCnt === len || (rCnt + 1) === len && cell.level > -1 &&
                    engine.headerContent[(rCnt + 1)][cCnt]
                    && engine.headerContent[(rCnt + 1)][cCnt].level === -1)
                    && this.parent.dataSourceSettings.valueAxis === 'column') {
                    tCell.querySelector('div div').appendChild(ej2_base_1.createElement('span', {
                        className: (vSort.sortOrder === 'Descending' ?
                            'e-icon-descending e-icons e-descending e-sortfilterdiv e-value-sort-icon' :
                            'e-icon-ascending e-icons e-ascending e-sortfilterdiv e-value-sort-icon') + (cell.hasChild ? ' e-value-sort-align' : ''),
                        styles: column.headerTextAlign === 'Right' ? 'float : left' : ''
                    }));
                }
            }
            return tCell;
        };
        Render.prototype.onResizeStop = function (args) {
            if (args.column.columns && args.column.columns.length > 0) {
                this.getChildColumnWidth(args.column.columns);
            }
            else {
                var column = args.column.field === '0.formattedText' ? '0.formattedText' :
                    args.column.customAttributes.cell.valueSort.levelName;
                this.parent.resizeInfo[column] = Number(args.column.width.toString().split('px')[0]);
            }
            if (this.parent.enableVirtualization && args.column.field === '0.formattedText') {
                if (this.parent.dataSourceSettings.values.length > 1
                    && !ej2_base_1.isNullOrUndefined(this.parent.grid.columns[this.parent.grid.columns.length - 1].columns)) {
                    var gridColumns = this.parent.grid.columns[this.parent.grid.columns.length - 1].columns;
                    gridColumns[gridColumns.length - 1].minWidth = this.parent.gridSettings.columnWidth;
                }
                else {
                    this.parent.grid.columns[this.parent.grid.columns.length - 1].minWidth =
                        this.parent.gridSettings.columnWidth;
                }
                this.parent.layoutRefresh();
            }
            this.setGroupWidth(args);
            this.calculateGridHeight(true);
            this.parent.grid.hideScroll();
        };
        Render.prototype.getChildColumnWidth = function (parentColumn) {
            for (var _i = 0, parentColumn_1 = parentColumn; _i < parentColumn_1.length; _i++) {
                var column = parentColumn_1[_i];
                if (column.columns && column.columns.length > 0) {
                    this.getChildColumnWidth(column.columns);
                }
                else {
                    var colName = column.customAttributes.cell.valueSort.levelName;
                    this.parent.resizeInfo[colName] = Number(column.width.toString().split('px')[0]);
                }
            }
        };
        Render.prototype.setGroupWidth = function (args) {
            if (this.parent.enableVirtualization && args.column.field === '0.formattedText') {
                if (this.parent.showGroupingBar && this.parent.groupingBarModule && this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS) && Number(args.column.width.toString().split('px')[0]) < 250) {
                    args.cancel = true;
                }
            }
            if (this.parent.showGroupingBar && this.parent.groupingBarModule &&
                this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS)) {
                this.parent.groupingBarModule.refreshUI();
                if (this.parent.element.querySelector('.e-group-row').offsetWidth < 245 && !this.parent.firstColWidth) {
                    args.cancel = true;
                    var gridColumn = this.parent.grid.columns;
                    if (gridColumn && gridColumn.length > 0) {
                        gridColumn[0].width = this.resColWidth;
                    }
                    this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('col').style.width = (this.resColWidth + 'px');
                    this.parent.element.querySelector('.' + cls.CONTENT_CLASS).querySelector('col').style.width = (this.resColWidth + 'px');
                }
                this.parent.element.querySelector('.e-group-rows').style.height = 'auto';
                this.parent.element.querySelector('.e-group-values').style.width =
                    this.parent.element.querySelector('.e-group-row').offsetWidth + 'px';
                var firstRowHeight = this.parent.element.querySelector('.' + cls.HEADERCONTENT).offsetHeight;
                this.parent.element.querySelector('.e-group-rows').style.height = firstRowHeight + 'px';
            }
            if (args.cancel) {
                var column = args.column.field === '0.formattedText' ? '0.formattedText' :
                    args.column.customAttributes.cell.valueSort.levelName;
                this.parent.resizeInfo[column] = Number(args.column.width.toString().split('px')[0]);
                if (this.parent.enableVirtualization) {
                    this.parent.layoutRefresh();
                }
            }
            if (this.parent.enableVirtualization) {
                this.parent.resizedValue = (args.cancel || args.column.field !== '0.formattedText') ? this.parent.resizedValue : Number(args.column.width.toString().split('px')[0]);
            }
            this.parent.trigger(args.e.type === 'touchend' || args.e.type === 'mouseup' ? events.resizeStop : events.resizing, args);
        };
        Render.prototype.selected = function () {
            clearTimeout(this.timeOutObj);
            this.timeOutObj = setTimeout(this.onSelect.bind(this), 300);
        };
        Render.prototype.onSelect = function () {
            var pivotArgs = { selectedCellsInfo: [], pivotValues: this.parent.pivotValues, currentCell: null };
            var selectedElements = this.parent.element.querySelectorAll('.'
                + cls.CELL_SELECTED_BGCOLOR + ',.' + cls.SELECTED_BGCOLOR);
            for (var i = 0; i < selectedElements.length; i++) {
                var element = selectedElements[i];
                var colIndex = Number(element.getAttribute('data-colindex'));
                var rowIndex = Number(element.getAttribute('index'));
                var cell = this.engine.pivotValues[rowIndex][colIndex];
                Eif (cell) {
                    if (cell.axis === 'value') {
                        pivotArgs.selectedCellsInfo.push({
                            currentCell: cell,
                            value: cell.value,
                            columnHeaders: cell.columnHeaders,
                            rowHeaders: cell.rowHeaders,
                            measure: cell.actualText.toString()
                        });
                    }
                    else if (cell.axis === 'column') {
                        pivotArgs.selectedCellsInfo.push({
                            currentCell: cell,
                            value: cell.formattedText,
                            columnHeaders: cell.valueSort.levelName,
                            rowHeaders: '',
                            measure: ''
                        });
                    }
                    else {
                        pivotArgs.selectedCellsInfo.push({
                            currentCell: cell,
                            value: cell.formattedText,
                            columnHeaders: '',
                            rowHeaders: cell.valueSort.levelName,
                            measure: ''
                        });
                    }
                }
            }
            this.parent.trigger(events.cellSelected, pivotArgs);
        };
        Render.prototype.rowCellBoundEvent = function (args) {
            var tCell = args.cell;
            if (tCell && (this.parent.notEmpty) && this.engine.headerContent) {
                var customClass = this.parent.hyperlinkSettings.cssClass;
                var cell = args.data[0];
                var isRowFieldsAvail = cell.valueSort && cell.valueSort.levelName === (this.parent.dataSourceSettings.rows.length === 0 && this.parent.dataSourceSettings.valueAxis === 'row' &&
                    this.parent.localeObj.getConstant('grandTotal') + (this.parent.dataSourceSettings.valueSortSettings.headerDelimiter) + (cell.formattedText));
                tCell.setAttribute('index', cell.rowIndex ? cell.rowIndex.toString() : '0');
                var pivotValue = this.parent.pivotValues[cell.rowIndex] && this.parent.pivotValues[cell.rowIndex][Number(tCell.getAttribute('data-colindex'))] ? this.parent.pivotValues[cell.rowIndex][Number(tCell.getAttribute('data-colindex'))] : null;
                if (tCell.getAttribute('data-colindex') === '0') {
                    if (this.parent.dataType === 'pivot') {
                        var isValueCell = cell.type && cell.type === 'value';
                        tCell.innerText = '';
                        var levelName = cell.valueSort ? cell.valueSort.levelName.toString() : '';
                        var memberPos = cell.actualText ?
                            cell.actualText.toString().split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length : 0;
                        var levelPosition = levelName.split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length -
                            (memberPos ? memberPos - 1 : memberPos);
                        var level = levelPosition ? (levelPosition - 1) : 0;
                        Iif (this.parent.dataSourceSettings.subTotalsPosition === 'Bottom' && !ej2_base_1.isNullOrUndefined(levelName)) {
                            var cellLevelName = !cell.isSum ? levelName : cell.type === 'value' ?
                                levelName.split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter + (this.parent.engineModule.valueAxisFields[cell.actualText].caption ?
                                    this.parent.engineModule.valueAxisFields[cell.actualText].caption :
                                    this.parent.engineModule.valueAxisFields[cell.actualText].name))[0] : '';
                            if (cell.isSum && (cell.type === 'value' ? this.drilledLevelInfo[cellLevelName] : true)) {
                                level = level - 1;
                            }
                            else if (!cell.isSum) {
                                if (cellLevelName.split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length === 1) {
                                    this.drilledLevelInfo = {};
                                }
                                if (cell.members && cell.members.length > 0) {
                                    this.drilledLevelInfo[cellLevelName] = cell.isDrilled;
                                }
                            }
                        }
                        do {
                            if (level > 0) {
                                tCell.appendChild(ej2_base_1.createElement('span', {
                                    className: level === 0 ? '' : cls.NEXTSPAN
                                }));
                            }
                            level--;
                        } while (level > -1);
                        level = levelPosition ? (levelPosition - 1) : 0;
                        this.lastSpan = levelPosition ? this.lastSpan : 0;
                        if (!cell.hasChild && (!isValueCell ? level : 0) > 0) {
                            tCell.appendChild(ej2_base_1.createElement('span', {
                                className: cls.LASTSPAN
                            }));
                        }
                        var fieldName = void 0;
                        if ((this.parent.dataSourceSettings.rows.length > 0 &&
                            (cell.valueSort ? Object.keys(cell.valueSort).length > 0 : true))) {
                            if (isValueCell) {
                                for (var _i = 0, _a = this.parent.dataSourceSettings.values; _i < _a.length; _i++) {
                                    var field = _a[_i];
                                    var name_1 = field.caption ? field.caption : field.name;
                                    if (levelName.indexOf(name_1) > -1) {
                                        fieldName = field.name;
                                        break;
                                    }
                                }
                            }
                            else {
                                fieldName = cell.level > -1 && this.parent.dataSourceSettings.rows[cell.level] ?
                                    this.parent.dataSourceSettings.rows[cell.level].name : '';
                            }
                            tCell.setAttribute('fieldname', fieldName);
                        }
                    }
                    else {
                        tCell = this.onOlapRowCellBoundEvent(tCell, cell);
                    }
                    var localizedText = cell.formattedText;
                    if (cell.type) {
                        if (cell.type === 'grand sum') {
                            this.rowGrandPos = cell.rowIndex;
                            tCell.classList.add('e-gtot');
                            var values = this.parent.dataSourceSettings.values;
                            localizedText = ej2_base_1.isNullOrUndefined(cell.valueSort.axis) ? (this.parent.dataSourceSettings.rows.length === 0 && values.length === 1 && this.parent.dataSourceSettings.valueAxis === 'row') ?
                                this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(values[values.length - 1].type) + ' ' +
                                    this.parent.localeObj.getConstant('of') + ' ' + (!ej2_base_1.isNullOrUndefined(values[values.length - 1].caption) ? values[values.length - 1].caption : values[values.length - 1].name) :
                                this.parent.localeObj.getConstant('grandTotal') : cell.formattedText;
                        }
                        else if (cell.valueSort.levelName === (this.parent.localeObj.getConstant('grandTotal') +
                            (this.parent.dataSourceSettings.valueSortSettings.headerDelimiter) + (cell.formattedText))) {
                            tCell.classList.add('e-gtot');
                            localizedText = isRowFieldsAvail ? this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(this.parent.engineModule.fieldList[cell.actualText].aggregateType) + ' '
                                + this.parent.localeObj.getConstant('of') + ' ' + cell.formattedText : localizedText;
                        }
                        else Iif (cell.type === 'sum' && cell.memberType !== 3) {
                            localizedText = cell.formattedText.split('Total')[0] + this.parent.localeObj.getConstant('total');
                        }
                        else {
                            tCell.classList.add('e-stot');
                        }
                    }
                    tCell.classList.add(cls.ROWSHEADER);
                    if (cell.hasChild === true && !cell.isNamedSet) {
                        tCell.appendChild(ej2_base_1.createElement('div', {
                            className: (cell.isDrilled === true ? cls.COLLAPSE : cls.EXPAND) + ' ' + cls.ICON,
                            attrs: {
                                'title': cell.isDrilled === true ? this.parent.localeObj.getConstant('collapse') :
                                    this.parent.localeObj.getConstant('expand')
                            }
                        }));
                    }
                    tCell.appendChild(ej2_base_1.createElement('span', {
                        className: cls.CELLVALUE,
                        innerHTML: (this.parent.isRowCellHyperlink || cell.enableHyperlink ? '<a  data-url="' + localizedText + '" class="e-hyperlinkcell ' + customClass + '">' + localizedText + '</a>' : localizedText)
                    }));
                    var vSort = this.parent.pivotView.dataSourceSettings.valueSortSettings;
                    if (this.parent.enableValueSorting) {
                        if (vSort && vSort.headerText && this.parent.dataSourceSettings.valueAxis === 'row' &&
                            this.parent.pivotValues[Number(tCell.getAttribute('index'))][0] &&
                            this.parent.pivotValues[Number(tCell.getAttribute('index'))][0].valueSort.levelName) {
                            if (this.parent.pivotValues[Number(tCell.getAttribute('index'))][0].valueSort.levelName
                                === vSort.headerText) {
                                tCell.appendChild(ej2_base_1.createElement('span', {
                                    className: (vSort.sortOrder === 'Descending' ?
                                        'e-icon-descending e-icons e-descending e-sortfilterdiv e-value-sort-icon' :
                                        'e-icon-ascending e-icons e-ascending e-sortfilterdiv e-value-sort-icon') + (cell.hasChild ? ' e-value-sort-align' : ''),
                                    styles: tCell.style.textAlign === 'right' ? 'float: left' : ''
                                }));
                            }
                        }
                    }
                }
                else {
                    var innerText = tCell.innerText;
                    tCell.innerText = '';
                    tCell.classList.add(cls.VALUESCONTENT);
                    cell = args.data[Number(tCell.getAttribute('data-colindex'))];
                    cell = ej2_base_1.isNullOrUndefined(cell) ? args.column.customAttributes.cell : cell;
                    cell.isGrandSum = isRowFieldsAvail ? true : cell.isGrandSum;
                    if (cell.isSum) {
                        tCell.classList.add(cls.SUMMARY);
                    }
                    var isGrandSum = (ej2_base_1.isNullOrUndefined(cell.isGrandSum) && (!ej2_base_1.isNullOrUndefined(this.parent.olapEngineModule) && this.parent.olapEngineModule.olapValueAxis === 'column') && this.parent.dataType === 'olap' &&
                        ((this.colGrandPos - this.parent.dataSourceSettings.values.length) < Number(tCell.getAttribute('data-colindex'))));
                    if (cell.isGrandSum || (isGrandSum || this.colGrandPos === Number(tCell.getAttribute('data-colindex'))) || this.rowGrandPos === Number(tCell.getAttribute('index'))) {
                        tCell.classList.add('e-gtot');
                    }
                    else if (this.parent.dataType === 'olap' ? cell.isSum : this.validateColumnTotalcell(cell.colIndex)) {
                        tCell.classList.add('e-colstot');
                    }
                    if (pivotValue && pivotValue.cssClass) {
                        tCell.classList.add(pivotValue.cssClass);
                    }
                    tCell.appendChild(ej2_base_1.createElement('span', {
                        className: cls.CELLVALUE,
                        innerHTML: ((tCell.className.indexOf('e-summary') !== -1 && this.parent.isSummaryCellHyperlink) ||
                            (tCell.className.indexOf('e-summary') === -1 && this.parent.isValueCellHyperlink) || cell.enableHyperlink ?
                            '<a data-url="' + innerText + '" class="e-hyperlinkcell ' + customClass + '">' + innerText + '</a>' : innerText)
                    }));
                    Iif (this.parent.gridSettings.allowReordering && !this.parent.showGroupingBar) {
                        tCell.setAttribute('data-colindex', args.column.customAttributes ? args.column.customAttributes.cell.colIndex.toString() : args.column.index.toString());
                    }
                }
                if (this.parent.cellTemplate) {
                    this.appendTemplate(tCell, pivotValue);
                }
                this.unWireEvents(tCell);
                this.wireEvents(tCell);
            }
            args.pivotview = this.parent;
            this.parent.trigger(events.queryCellInfo, args);
        };
        Render.prototype.appendTemplate = function (tCell, pivotValue) {
            var element = this.parent.getCellTemplate()({ targetCell: tCell, cellInfo: pivotValue }, this.parent, 'cellTemplate', this.parent.element.id +
                '_cellTemplate', null, null, tCell);
            Eif (element && element !== '' && element.length > 0) {
                Iif (this.parent.enableHtmlSanitizer) {
                    if (this.parent.isVue || this.parent.isVue3) {
                        var container = ej2_base_1.createElement('div');
                        container.innerHTML = ej2_base_2.SanitizeHtmlHelper.sanitize(element);
                        ej2_base_1.append([container.firstChild], tCell);
                    }
                    else {
                        this.parent.appendHtml(tCell, ej2_base_2.SanitizeHtmlHelper.sanitize(element[0].outerHTML));
                    }
                }
                else {
                    Iif (this.parent.isVue || this.parent.isVue3) {
                        ej2_base_1.append(element, tCell);
                    }
                    else {
                        this.parent.appendHtml(tCell, element[0].outerHTML);
                    }
                }
            }
        };
        Render.prototype.onOlapRowCellBoundEvent = function (tCell, cell) {
            tCell.innerText = '';
            var rowMeasurePos = this.engine.rowMeasurePos;
            if (this.parent.enableVirtualization) {
                Eif (cell.ordinal > -1 && this.parent.olapEngineModule.tupRowInfo.length > 0) {
                    var tupInfo = this.parent.olapEngineModule.tupRowInfo[cell.ordinal];
                    var cellActualText = cell.memberType === 3 ?
                        this.engine.fieldList[cell.actualText.toString()].tag.toString() :
                        cell.actualText.toString();
                    var memberPosition = tupInfo.uNameCollection.indexOf(cellActualText);
                    var cropUName = tupInfo.uNameCollection.substring(0, memberPosition) +
                        (cell.memberType === 3 ? '' : cell.actualText.toString());
                    var fieldSep = cropUName.split('::[').map(function (item) {
                        return item[0] === '[' ? item : ('[' + item);
                    });
                    Iif (cell.memberType === 3 && rowMeasurePos) {
                        fieldSep.push(cell.actualText.toString());
                    }
                    var nxtIndextCount = -1;
                    var lastIndextCount = 0;
                    var prevHasChild = false;
                    for (var fPos = 0; fPos < fieldSep.length; fPos++) {
                        var fieldMembers = fieldSep[fPos];
                        var membersCount = fieldMembers.split('~~').length;
                        nxtIndextCount += membersCount;
                        var hasChild = tupInfo.typeCollection[fPos] !== '2' ? (this.engine.fieldList[tupInfo.members[fPos].getAttribute('Hierarchy')] && this.engine.fieldList[tupInfo.members[fPos].getAttribute('Hierarchy')].isHierarchy && fPos < this.parent.dataSourceSettings.rows.length - 1 && !this.parent.dataSourceSettings.rows[fPos + 1].isNamedSet && this.parent.dataSourceSettings.rows[fPos + 1].name.indexOf('[Measures]') < 0 && this.engine.fieldList[this.parent.dataSourceSettings.rows[fPos + 1].name] && this.engine.fieldList[this.parent.dataSourceSettings.rows[fPos + 1].name].hasAllMember) ? true : Number(tupInfo.members[fPos].querySelector('CHILDREN_CARDINALITY').textContent) > 0 : false;
                        lastIndextCount += (fPos > 0 && prevHasChild && !hasChild) ? 1 : 0;
                        prevHasChild = hasChild;
                    }
                    var indent = 0;
                    for (var iPos = 0; iPos < nxtIndextCount; iPos++) {
                        tCell.appendChild(ej2_base_1.createElement('span', {
                            className: cls.NEXTSPAN
                        }));
                        indent++;
                    }
                    for (var iPos = 0; iPos < lastIndextCount && nxtIndextCount > 0; iPos++) {
                        tCell.appendChild(ej2_base_1.createElement('span', {
                            className: cls.LASTSPAN
                        }));
                    }
                    this.indentCollection[cell.rowIndex] = indent;
                    this.maxIndent = this.maxIndent > indent ? this.maxIndent : indent;
                }
            }
            else {
                var hierarchyName = cell.hierarchy;
                var actualLevelName = cell.valueSort ? cell.valueSort.levelName.toString() : '';
                var levelPosition = cell.level === -1 ? this.measurePos :
                    actualLevelName.split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length - 1;
                var levelName = cell.memberType === 3 ? (levelPosition + '.' + cell.levelUniqueName) : cell.levelUniqueName;
                var hasChild = cell.hasChild;
                var isSubTotalCell = false;
                Iif (cell.isSum && cell.memberType === 3) {
                    var currPos_1 = this.lvlCollection[cell.parentUniqueName].position;
                    for (var i = currPos_1 + 1; i < this.position; i++) {
                        delete this.lvlCollection[this.lvlPosCollection[i]];
                        delete this.lvlPosCollection[i];
                    }
                    this.position = this.position > (currPos_1 + 1) ? (currPos_1 + 1) : this.position;
                    isSubTotalCell = true;
                    this.measurePos = this.lvlCollection[cell.parentUniqueName].position;
                }
                if (!this.lvlCollection[levelName] && levelName) {
                    this.lvlPosCollection[this.position] = levelName;
                    this.lvlCollection[levelName] = { position: this.position, hasChild: hasChild };
                    this.position++;
                }
                else if (levelName) {
                    var currPos_2 = this.lvlCollection[levelName].position;
                    for (var pos = currPos_2 + 1; pos < this.position; pos++) {
                        delete this.lvlCollection[this.lvlPosCollection[pos]];
                        delete this.lvlPosCollection[pos];
                    }
                    this.position = this.position > (currPos_2 + 1) ? (currPos_2 + 1) : this.position;
                }
                if (!this.hierarchyCollection[hierarchyName] && hierarchyName) {
                    this.hierarchyPosCollection[this.hierarchyCount] = hierarchyName;
                    this.hierarchyCollection[hierarchyName] = {
                        lvlPosition: this.position - 1,
                        hierarchyPOs: this.hierarchyCount
                    };
                    this.hierarchyCount++;
                }
                else if (hierarchyName) {
                    var currPos_3 = this.hierarchyCollection[hierarchyName].hierarchyPOs;
                    for (var pos = currPos_3 + 1; pos < this.hierarchyCount; pos++) {
                        delete this.hierarchyCollection[this.hierarchyPosCollection[pos]];
                        delete this.hierarchyPosCollection[pos];
                    }
                    this.hierarchyCount = this.hierarchyCount > (currPos_3 + 1) ? (currPos_3 + 1) : this.hierarchyCount;
                }
                if (cell.memberType !== 3 && levelName && this.lvlCollection[levelName]) {
                    var currHierarchyPos = this.hierarchyCollection[hierarchyName] ?
                        this.hierarchyCollection[hierarchyName].hierarchyPOs : -1;
                    this.measurePos = rowMeasurePos <= currHierarchyPos && this.hierarchyPosCollection[rowMeasurePos + 1] ?
                        this.measurePos : this.lvlCollection[levelName].position;
                }
                var currPos = this.lvlCollection[levelName] ? this.lvlCollection[levelName].position : -1;
                currPos = isSubTotalCell ? currPos - 1 : currPos;
                var lvlPos = 0;
                var indent = 0;
                while (lvlPos <= currPos && currPos > 0 && cell.level > -1) {
                    var hasChild_1 = this.lvlCollection[this.lvlPosCollection[lvlPos]].hasChild;
                    var prevHasChild = lvlPos > 0 ? this.lvlCollection[this.lvlPosCollection[lvlPos - 1]].hasChild : false;
                    Iif (prevHasChild && !hasChild_1) {
                        tCell.appendChild(ej2_base_1.createElement('span', {
                            className: cls.LASTSPAN
                        }));
                    }
                    if (lvlPos !== currPos) {
                        tCell.appendChild(ej2_base_1.createElement('span', {
                            className: cls.NEXTSPAN
                        }));
                        indent++;
                    }
                    lvlPos++;
                }
                Iif (this.parent.dataSourceSettings.grandTotalsPosition === 'Top' && (!ej2_base_1.isNullOrUndefined(this.parent.olapEngineModule) && this.parent.olapEngineModule.olapValueAxis === 'row') && this.parent.dataType === 'olap' &&
                    (cell.valueSort.levelName.toString()).indexOf(this.parent.localeObj.getConstant('grandTotal') + this.parent.dataSourceSettings.valueSortSettings.headerDelimiter) === 0) {
                    tCell.appendChild(ej2_base_1.createElement('span', {
                        className: cls.NEXTSPAN
                    }));
                }
                Iif (cell.memberType === 3 && cell.level === -1 && Object.keys(this.lvlCollection).length > 1) {
                    tCell.appendChild(ej2_base_1.createElement('span', {
                        className: cls.NEXTSPAN
                    }));
                    indent++;
                }
                this.indentCollection[cell.rowIndex] = indent;
                this.maxIndent = this.maxIndent > indent ? this.maxIndent : indent;
            }
            tCell.setAttribute('fieldname', cell.hierarchy);
            var grandTotal = (this.parent.olapEngineModule.tupRowInfo[cell.ordinal] ?
                (this.parent.olapEngineModule.tupRowInfo[cell.ordinal].measurePosition === 0 ?
                    this.parent.olapEngineModule.tupRowInfo[cell.ordinal].allStartPos === 1 :
                    this.parent.olapEngineModule.tupRowInfo[cell.ordinal].allStartPos === 0) : false);
            if (grandTotal) {
                tCell.classList.add('e-gtot');
            }
            return tCell;
        };
        Render.prototype.columnCellBoundEvent = function (args) {
            if (args.cell.column && args.cell.column.customAttributes) {
                var cell = args.cell.column.customAttributes.cell;
                var tCell = args.node;
                Eif (cell) {
                    var customClass = this.parent.hyperlinkSettings.cssClass;
                    var isValueCell = false;
                    for (var _i = 0, _a = this.parent.dataSourceSettings.values; _i < _a.length; _i++) {
                        var field = _a[_i];
                        if (field.name === cell.actualText) {
                            isValueCell = true;
                            tCell.setAttribute('fieldname', field.name);
                        }
                    }
                    if ((cell.level === -1 && !cell.rowSpan) || cell.rowSpan === -1) {
                        args.node.style.display = 'none';
                    }
                    else if (cell.rowSpan > 1) {
                        args.node.setAttribute('rowspan', cell.rowSpan.toString());
                        args.node.setAttribute('aria-rowspan', cell.rowSpan.toString());
                        if ((cell.rowIndex + cell.rowSpan) === this.engine.headerContent.length) {
                            args.node.style.borderBottomWidth = '0px';
                        }
                    }
                    args.node.setAttribute('data-colindex', cell.colIndex.toString());
                    args.node.setAttribute('index', cell.rowIndex.toString());
                    var fieldName = void 0;
                    if (this.parent.dataType === 'pivot') {
                        if (!isValueCell && !(this.parent.dataSourceSettings.values && this.parent.dataSourceSettings.valueAxis === 'column' &&
                            this.parent.dataSourceSettings.values.length > 1 &&
                            (isValueCell && cell.rowIndex === this.engine.headerContent.length - 1)) && this.parent.dataSourceSettings.columns
                            && this.parent.dataSourceSettings.columns.length > 0) {
                            fieldName = cell.level > -1 && this.parent.dataSourceSettings.columns[cell.level] ?
                                this.parent.dataSourceSettings.columns[cell.level].name : '';
                            tCell.setAttribute('fieldname', fieldName);
                        }
                        if (this.validateColumnTotalcell(cell.colIndex)) {
                            tCell.classList.add('e-colstot');
                        }
                    }
                    else {
                        tCell = this.onOlapColumnCellBoundEvent(tCell, cell);
                    }
                    var isColumnFieldsAvail = (this.parent.dataSourceSettings.columns.length === 0 && this.parent.dataSourceSettings.valueAxis === 'column' && cell.valueSort &&
                        cell.valueSort.levelName === (this.parent.localeObj.getConstant('grandTotal') + (this.parent.dataSourceSettings.valueSortSettings.headerDelimiter) + (cell.formattedText)));
                    if (cell.type || isColumnFieldsAvail) {
                        tCell.classList.add(cell.type === 'grand sum' ? 'e-gtot' : 'e-stot');
                        if (cell.type === 'grand sum') {
                            this.colGrandPos = cell.colIndex;
                        }
                        else if (cell.type) {
                            tCell.classList.add('e-colstot');
                        }
                        var engine = this.parent.dataType === 'olap' ? this.parent.olapEngineModule : this.parent.engineModule;
                        var localizedText = cell.type === 'grand sum' ? (ej2_base_1.isNullOrUndefined(cell.valueSort.axis) || this.parent.dataType === 'olap' ? this.parent.localeObj.getConstant('grandTotal') :
                            cell.formattedText) : cell.formattedText.split('Total')[0] + this.parent.localeObj.getConstant('total');
                        localizedText = isColumnFieldsAvail && engine.fieldList ? this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(engine.fieldList[cell.actualText].aggregateType)
                            + ' ' + this.parent.localeObj.getConstant('of') + ' ' + cell.formattedText : localizedText;
                        if (tCell.querySelector('.e-headertext') !== null) {
                            tCell.querySelector('.e-headertext').innerText = localizedText;
                        }
                        else {
                            tCell.querySelector('.e-stackedheadercelldiv').innerText = localizedText;
                        }
                    }
                    tCell.classList.add(cls.COLUMNSHEADER);
                    if (this.parent.isColumnCellHyperlink || cell.enableHyperlink) {
                        if (tCell.querySelector('.e-stackedheadercelldiv')) {
                            var innerText = tCell.querySelector('.e-stackedheadercelldiv').innerText;
                            tCell.querySelector('.e-stackedheadercelldiv').innerHTML =
                                '<a data-url="' + innerText + '" class="e-hyperlinkcell ' + customClass + '">' + innerText + '</a>';
                        }
                        else Eif (tCell.querySelector('.e-headertext')) {
                            var innerText = tCell.querySelector('.e-headertext').innerText;
                            tCell.querySelector('.e-headertext').innerHTML =
                                '<a data-url="' + innerText + '" class="e-hyperlinkcell ' + customClass + '">' + innerText + '</a>';
                        }
                    }
                    if (cell.hasChild === true && !cell.isNamedSet) {
                        var hdrdiv = tCell.querySelector('.e-headercelldiv');
                        if (hdrdiv) {
                            hdrdiv.style.height = 'auto';
                            hdrdiv.style.lineHeight = 'normal';
                        }
                        var div = ej2_base_1.createElement('div', {
                            className: (cell.isDrilled === true ? cls.COLLAPSE : cls.EXPAND) + ' ' + cls.ICON,
                            attrs: {
                                'title': cell.isDrilled === true ? this.parent.localeObj.getConstant('collapse') :
                                    this.parent.localeObj.getConstant('expand')
                            }
                        });
                        Iif (window.navigator.userAgent.indexOf('Edge') > -1 || window.navigator.userAgent.indexOf('Trident') > -1) {
                            tCell.children[0].style.display = 'table';
                        }
                        else {
                            tCell.children[0].style.display = 'block';
                        }
                        this.updateWrapper(tCell, div);
                    }
                    else {
                        this.updateWrapper(tCell);
                    }
                    tCell = this.appendValueSortIcon(cell, tCell, cell.rowIndex, cell.colIndex, args.cell.column);
                    if (this.parent.cellTemplate) {
                        this.appendTemplate(tCell, cell);
                    }
                    var len = this.parent.dataSourceSettings.values.length;
                    for (var vCnt = 0; vCnt < len; vCnt++) {
                        if (this.parent.dataSourceSettings.values[vCnt].name === cell.actualText) {
                            if (this.parent.dataType === 'olap') {
                                var grandTotal = (this.parent.olapEngineModule.tupColumnInfo[cell.ordinal] ?
                                    (this.parent.olapEngineModule.tupColumnInfo[cell.ordinal].measurePosition === 0 ?
                                        this.parent.olapEngineModule.tupColumnInfo[cell.ordinal].allStartPos === 1 :
                                        this.parent.olapEngineModule.tupColumnInfo[cell.ordinal].allStartPos === 0) : false);
                                if (grandTotal) {
                                    tCell.classList.add('e-gtot');
                                }
                            }
                            if (cell.valueSort.levelName === (this.parent.localeObj.getConstant('grandTotal') + (this.parent.dataSourceSettings.valueSortSettings.headerDelimiter) + (cell.formattedText))
                                || cell.valueSort.levelName === ('Grand Total' + (this.parent.dataSourceSettings.valueSortSettings.headerDelimiter) + (cell.formattedText))) {
                                tCell.classList.add('e-gtot');
                            }
                            else {
                                tCell.classList.add(cls.VALUESHEADER);
                            }
                        }
                    }
                    this.unWireEvents(tCell);
                    this.wireEvents(tCell);
                }
            }
            this.parent.trigger(events.headerCellInfo, args);
        };
        Render.prototype.updateWrapper = function (tCell, div) {
            Eif (tCell.querySelectorAll('.e-headercelldiv').length > 0 || tCell.querySelectorAll('.e-stackedheadercelldiv').length > 0) {
                var outerDiv = ej2_base_1.createElement('div', {
                    className: cls.PIVOT_CELL_CONTAINER
                });
                var innerDiv = ej2_base_1.createElement('div', {
                    className: (div ? 'e-stackedheadertext' : 'e-headertext') + ' ' + cls.CELLVALUE,
                    innerHTML: tCell.querySelectorAll('.e-headercelldiv').length > 0 ? tCell.querySelector('.e-headercelldiv').innerHTML : tCell.querySelector('.e-stackedheadercelldiv').innerHTML
                });
                if (div) {
                    outerDiv.append(div);
                }
                outerDiv.append(innerDiv);
                tCell.children[0].innerHTML = '';
                tCell.children[0].append(outerDiv);
            }
            return tCell;
        };
        Render.prototype.onOlapColumnCellBoundEvent = function (tCell, cell) {
            tCell.setAttribute('fieldname', cell.memberType === 3 ? cell.actualText.toString() : cell.hierarchy);
            var prevCell = this.engine.headerContent[cell.rowIndex] ?
                this.engine.headerContent[cell.rowIndex][cell.colIndex - 1] : undefined;
            if (prevCell && prevCell.actualText === cell.actualText && prevCell.type === cell.type &&
                (prevCell.colSpan > 1)) {
                tCell.style.display = 'none';
            }
            else {
            }
            if (cell.rowIndex === (this.engine.headerContent.length - 1) && cell.memberType === 2) {
                tCell.style.display = this.isSpannedCell(this.engine.headerContent.length, cell) ? 'none' : tCell.style.display;
            }
            return tCell;
        };
        Render.prototype.isSpannedCell = function (colLength, currCell) {
            var prevCell = this.engine.headerContent[currCell.rowIndex - 1] ?
                this.engine.headerContent[currCell.rowIndex - 1][currCell.colIndex] : undefined;
            var parentCellSpan;
            var parentCellPos;
            while (prevCell && ((prevCell.memberType === currCell.memberType) || (prevCell.type && currCell.type))) {
                Eif (prevCell.rowSpan > 0) {
                    parentCellSpan = prevCell.rowSpan;
                    parentCellPos = prevCell.rowIndex;
                }
                prevCell = this.engine.headerContent[prevCell.rowIndex - 1] ?
                    this.engine.headerContent[prevCell.rowIndex - 1][currCell.colIndex] : undefined;
            }
            return (parentCellPos + parentCellSpan) >= colLength;
        };
        Render.prototype.onHyperCellClick = function (e) {
            var cell = e.target.parentElement.parentElement;
            cell = (cell.className.indexOf('e-headercelldiv') > -1 ? cell.parentElement : cell);
            var args = {
                currentCell: cell,
                data: this.engine.pivotValues[Number(cell.getAttribute('index'))][Number(cell.getAttribute('data-colindex'))],
                cancel: true,
                nativeEvent: e
            };
            this.parent.trigger(events.hyperlinkCellClick, args, function (observedArgs) {
                if (!observedArgs.cancel) {
                    args.currentCell = ej2_base_1.getElement(args.currentCell);
                    var url = args.currentCell.getAttribute('data-url') ? (args.currentCell).getAttribute('data-url') :
                        args.currentCell.querySelector('a').getAttribute('data-url');
                    window.open(url);
                }
            });
        };
        Render.prototype.getRowStartPos = function () {
            var pivotValues = this.parent.pivotValues;
            var rowPos;
            for (var rCnt = 0; rCnt < (pivotValues ? pivotValues.length : 0); rCnt++) {
                if (pivotValues[rCnt] && pivotValues[rCnt][0] && pivotValues[rCnt][0].axis === 'row') {
                    rowPos = rCnt;
                    break;
                }
            }
            return rowPos;
        };
        Render.prototype.frameDataSource = function (type) {
            var dataContent = [];
            if (((this.parent.dataType === 'pivot' && this.parent.dataSourceSettings.dataSource && this.parent.engineModule.data.length > 0) || (this.parent.dataType === 'olap' && this.parent.dataSourceSettings.url !== '') ||
                (this.parent.dataSourceSettings.mode === 'Server' && this.parent.dataSourceSettings.url !== '' && this.engine.pivotValues.length > 0)) && this.parent.dataSourceSettings.values.length > 0 && !this.engine.isEmptyData) {
                Eif ((this.parent.enableValueSorting) || !this.engine.isEngineUpdated) {
                    var rowCnt = 0;
                    var pivotValues = this.parent.pivotValues;
                    var start = type === 'value' ? this.rowStartPos : 0;
                    var end = type === 'value' ? (pivotValues ? pivotValues.length : 0) : this.rowStartPos;
                    for (var rCnt = start; rCnt < end; rCnt++) {
                        Eif (pivotValues[rCnt]) {
                            rowCnt = type === 'header' ? rCnt : rowCnt;
                            dataContent[rowCnt] = {};
                            for (var cCnt = 0; cCnt < pivotValues[rCnt].length; cCnt++) {
                                if (pivotValues[rCnt][cCnt]) {
                                    dataContent[rowCnt][cCnt] = pivotValues[rCnt][cCnt];
                                }
                            }
                            rowCnt++;
                        }
                    }
                }
                else {
                    dataContent = type === 'value' ? this.engine.valueContent : this.engine.headerContent;
                }
            }
            else {
                dataContent = this.frameEmptyData();
            }
            return dataContent;
        };
        Render.prototype.frameEmptyData = function () {
            var dataContent = [{
                    0: { formattedText: this.parent.localeObj.getConstant('grandTotal') },
                    1: { formattedText: this.parent.localeObj.getConstant('emptyData') }
                }];
            return dataContent;
        };
        Render.prototype.calculateColWidth = function (colCount) {
            Iif (!ej2_base_1.isNullOrUndefined(this.parent.resizedValue)) {
                this.parent.resizedValue = (this.parent.showGroupingBar && this.parent.resizedValue < 250) ? 250 : this.parent.resizedValue;
            }
            this.resColWidth = !ej2_base_1.isNullOrUndefined(this.parent.resizedValue) ? this.parent.resizedValue : this.resColWidth;
            var offsetWidth = this.calculateGridWidth();
            var parWidth = isNaN(this.parent.width) ? (this.parent.width.toString().indexOf('%') > -1 ?
                ((parseFloat(this.parent.width.toString()) / 100) * offsetWidth) : offsetWidth) :
                Number(this.parent.width);
            parWidth = parWidth - (this.gridSettings.columnWidth > this.resColWidth ? this.gridSettings.columnWidth : this.resColWidth);
            colCount = colCount - 1;
            this.isOverflows = !((colCount * this.gridSettings.columnWidth) < parWidth);
            if (!this.isOverflows) {
                var gridHeight = this.calculateGridHeight();
                var parentHeight = gridHeight === 'auto' ? this.parent.getHeightAsNumber() : gridHeight;
                var headersLength = (this.engine && this.engine.headerContent) ? Object.keys(this.engine.headerContent).length : 1;
                var height = parentHeight - (this.gridSettings.rowHeight * headersLength);
                if (this.engine && this.engine.valueContent && ((this.gridSettings.rowHeight * this.engine.valueContent.length) > height)) {
                    parWidth = parWidth - ej2_grids_1.getScrollBarWidth();
                }
            }
            var colWidth = (colCount * this.gridSettings.columnWidth) < parWidth ? (parWidth / colCount) : this.gridSettings.columnWidth;
            return (!this.isOverflows && !this.gridSettings.allowAutoResizing) ? this.gridSettings.columnWidth : Math.floor(colWidth);
        };
        Render.prototype.resizeColWidth = function (colCount) {
            if (!ej2_base_1.isNullOrUndefined(this.parent.resizedValue)) {
                this.parent.resizedValue = (this.parent.showGroupingBar && this.parent.resizedValue < 250) ? 250 : this.parent.resizedValue;
            }
            this.resColWidth = !ej2_base_1.isNullOrUndefined(this.parent.resizedValue) ? this.parent.resizedValue : this.resColWidth;
            var parWidth = isNaN(this.parent.width) ? (this.parent.width.toString().indexOf('%') > -1 ?
                ((parseFloat(this.parent.width.toString()) / 100) * this.parent.element.offsetWidth) : this.parent.element.offsetWidth) :
                Number(this.parent.width);
            colCount = colCount - 1;
            parWidth = parWidth - (this.gridSettings.columnWidth > this.resColWidth ? this.gridSettings.columnWidth : this.resColWidth);
            this.isOverflows = !((colCount * this.gridSettings.columnWidth) < parWidth);
            var colWidth = (colCount * this.gridSettings.columnWidth) < parWidth ? (parWidth / colCount) : this.gridSettings.columnWidth;
            return (!this.isOverflows && !this.gridSettings.allowAutoResizing) ? this.gridSettings.columnWidth : Math.floor(colWidth);
        };
        Render.prototype.calculateGridWidth = function () {
            var parWidth = this.parent.width;
            var eleWidth = this.parent.element.getBoundingClientRect().width ?
                this.parent.element.getBoundingClientRect().width : this.parent.element.offsetWidth;
            Iif (eleWidth === 0) {
                eleWidth = this.parent.element.parentElement.getBoundingClientRect().width ?
                    this.parent.element.parentElement.getBoundingClientRect().width : this.parent.element.parentElement.offsetWidth;
            }
            Eif (this.gridSettings.width === 'auto') {
                if (this.parent.width === 'auto') {
                    parWidth = eleWidth;
                }
                else if (this.parent.width.toString().indexOf('%') > -1) {
                    parWidth = ((parseFloat(this.parent.width.toString()) / 100) * eleWidth);
                }
                else Iif (this.parent.width.toString().indexOf('px') > -1) {
                    parWidth = this.parent.width.toString().split('px')[0];
                }
            }
            else {
                parWidth = this.gridSettings.width;
            }
            return (!this.gridSettings.allowAutoResizing && parWidth > this.parent.totColWidth) ? this.parent.totColWidth : parWidth;
        };
        Render.prototype.calculateGridHeight = function (elementCreated) {
            var contentElement = this.parent.element.querySelector('.' + cls.GRID_CLASS + ' .' + cls.CONTENT_CLASS);
            var gridHeight = this.parent.height;
            var parHeight = this.parent.getHeightAsNumber();
            if (contentElement) {
                Iif (isNaN(parHeight)) {
                    parHeight = parHeight > this.parent.minHeight ? parHeight : this.parent.minHeight;
                }
                else {
                    parHeight = (contentElement.offsetWidth < contentElement.querySelector('.' + cls.TABLE).offsetWidth) ?
                        parHeight - ej2_grids_1.getScrollBarWidth() : parHeight;
                }
                if ((this.parent.showToolbar && this.parent.currentView !== 'Chart') || (!this.parent.showToolbar && this.parent.displayOption.view !== 'Chart')) {
                    Eif (this.gridSettings.height === 'auto' && parHeight && this.parent.element.querySelector('.' + cls.GRID_HEADER)) {
                        var rowColHeight = this.parent.element.querySelector('.' + cls.GRID_HEADER).offsetHeight;
                        var gBarHeight = rowColHeight + (this.parent.element.querySelector('.' + cls.GRID_GROUPING_BAR_CLASS) ?
                            this.parent.element.querySelector('.' + cls.GRID_GROUPING_BAR_CLASS).offsetHeight : 0);
                        var toolBarHeight = this.parent.element.querySelector('.' + cls.GRID_TOOLBAR) ? 42 : 0;
                        var pagerHeight = this.parent.element.querySelector('.' + cls.GRID_PAGER) ? this.parent.element.querySelector('.' + cls.GRID_PAGER).offsetHeight : 0;
                        gridHeight = parHeight - (gBarHeight + toolBarHeight + pagerHeight) - 1;
                        gridHeight = gridHeight < 40 ? 40 : gridHeight;
                        if (elementCreated) {
                            var tableHeight = contentElement.querySelector('.' + cls.TABLE).offsetHeight;
                            var contentHeight = contentElement.querySelector('.' + cls.TABLE).offsetHeight;
                            var tableWidth = contentElement.querySelector('.' + cls.TABLE).offsetWidth;
                            var contentWidth = contentElement.offsetWidth;
                            var horizontalOverflow = contentWidth <= tableWidth;
                            var commonOverflow = horizontalOverflow && ((gridHeight - tableHeight) < 18) ? true : false;
                            if (gridHeight >= tableHeight && (horizontalOverflow ? gridHeight >= contentHeight : true) &&
                                !commonOverflow) {
                                this.parent.grid.height = 'auto';
                            }
                            else {
                                this.parent.grid.height = gridHeight;
                                this.parent.grid.dataBind();
                            }
                        }
                        else {
                            if (gridHeight > (this.engine.valueContent.length * this.gridSettings.rowHeight)) {
                                gridHeight = 'auto';
                            }
                        }
                    }
                    else {
                        gridHeight = this.gridSettings.height;
                    }
                }
            }
            return gridHeight < this.parent.gridSettings.rowHeight ? this.parent.gridSettings.rowHeight : gridHeight;
        };
        Render.prototype.frameStackedHeaders = function () {
            var pivotColumns = this.parent.pivotColumns;
            var engine = this.parent.dataType === 'pivot' ? this.parent.engineModule : this.parent.olapEngineModule;
            var gridColumns = this.parent.grid['columnModel'];
            var autoFitApplied = false;
            var refreshColumn = this.parent.toolbarModule && this.parent.toolbarModule.isReportChange ? true : this.parent.actionObj ? ((this.parent.actionObj.actionName === 'Sort value' && engine.valueAxis === 1) ||
                (this.parent.actionObj.actionName === 'Sort field' && this.parent.actionObj.fieldInfo.axis === 'columns') ||
                (this.parent.pivotFieldListModule && this.parent.pivotFieldListModule.actionObj.actionName === 'Sort field' && this.parent.pivotFieldListModule.actionObj.fieldInfo.axis === 'columns')) : false;
            this.pivotColumns = [];
            if ((((this.parent.dataType === 'olap' && this.parent.dataSourceSettings.url !== '') ? true : (this.parent.dataSourceSettings.values.length > 0 && this.parent.dataSourceSettings.dataSource && this.parent.engineModule.data.length > 0)) ||
                (this.parent.dataSourceSettings.mode === 'Server' && this.parent.dataSourceSettings.url !== '' && this.engine.pivotValues.length > 0)) && !this.engine.isEmptyData) {
                var headerCnt = this.engine.headerContent.length;
                var headerSplit = [];
                var splitPos = [];
                var colWidth = this.calculateColWidth(this.engine.pivotValues && this.engine.pivotValues[0] ?
                    this.engine.pivotValues[0].length : 0);
                var measureFlag = this.parent.dataType === 'olap' && !ej2_base_1.isNullOrUndefined(this.engine.colMeasurePos) && this.engine.colDepth - 1 === this.parent.olapEngineModule.colMeasurePos;
                do {
                    var columnModel = [];
                    var actualCnt = 0;
                    headerCnt--;
                    var colField = this.engine.headerContent[headerCnt];
                    var colCount = colField ? Object.keys(colField).length : 0;
                    if (colField) {
                        for (var cCnt = 0, cLen = Object.keys(colField).length + (colField[0] ? 0 : 1); cCnt < cLen; cCnt++) {
                            var colSpan = (colField[cCnt] && colField[cCnt].colSpan) ?
                                ((colField[cCnt].memberType !== 3 || (colField[cCnt].memberType === 3 && !measureFlag) ||
                                    headerCnt === 0) ? colField[cCnt].colSpan : headerSplit[cCnt]) : 1;
                            colSpan = this.parent.dataType === 'olap' && ej2_base_1.isNullOrUndefined(colSpan) ? 1 : colSpan;
                            var formattedText = colField[cCnt] ? (colField[cCnt].type === 'grand sum' ?
                                (ej2_base_1.isNullOrUndefined(colField[cCnt].valueSort.axis) ? this.parent.localeObj.getConstant('grandTotal') :
                                    colField[cCnt].formattedText) : (colField[cCnt].type === 'sum' ?
                                colField[cCnt].formattedText.split('Total')[0] + this.parent.localeObj.getConstant('total') :
                                colField[cCnt].formattedText)) : '';
                            formattedText = this.parent.enableHtmlSanitizer ? ej2_base_2.SanitizeHtmlHelper.sanitize(formattedText) : formattedText;
                            if (headerCnt === this.engine.headerContent.length - 1) {
                                colSpan = 1;
                                autoFitApplied = pivotColumns.length - 1 !== colCount ? false : (!refreshColumn && !this.parent.isEmptyGrid
                                    && pivotColumns[actualCnt] && pivotColumns[actualCnt].autoFit);
                                columnModel[actualCnt] = {
                                    field: (cCnt + '.formattedText'),
                                    headerText: formattedText,
                                    customAttributes: { 'cell': this.cloneDataWithoutIndex(colField[cCnt]) },
                                    width: autoFitApplied ? gridColumns[actualCnt].width : colField[cCnt]
                                        ? colField[cCnt].valueSort ? this.setSavedWidth(colField[cCnt]
                                            .valueSort.levelName, colWidth) : this.resColWidth : this.resColWidth,
                                    minWidth: autoFitApplied && actualCnt === colCount
                                        ? gridColumns[gridColumns.length - 1].minWidth : 30,
                                    allowReordering: (this.parent.showGroupingBar ? false : this.parent.gridSettings.allowReordering),
                                    allowResizing: this.parent.gridSettings.allowResizing,
                                    visible: true,
                                    textAlign: this.parent.enableRtl ? 'Left' : 'Right',
                                    headerTextAlign: this.parent.enableRtl ? 'Right' : 'Left'
                                };
                                if (cCnt === colCount) {
                                    columnModel[actualCnt].width = (columnModel[actualCnt].width - 3);
                                    this.lastColumn = columnModel[actualCnt];
                                }
                            }
                            else Eif (headerSplit[cCnt]) {
                                var tmpSpan = colSpan;
                                var innerModel = [];
                                var innerPos = cCnt;
                                while (tmpSpan > 0) {
                                    if (columnModel[actualCnt]) {
                                        Iif (!this.pivotColumns[splitPos[innerPos]]) {
                                            break;
                                        }
                                        innerModel.push(this.pivotColumns[splitPos[innerPos]]);
                                    }
                                    else {
                                        columnModel[actualCnt] = {
                                            headerText: formattedText,
                                            field: colField[cCnt] ? colField[cCnt].valueSort
                                                .levelName : '',
                                            customAttributes: { 'cell': this.cloneDataWithoutIndex(colField[cCnt]) },
                                            width: (autoFitApplied && actualCnt === 0 && !refreshColumn && !this.parent.isEmptyGrid
                                                && pivotColumns[0].autoFit) ? gridColumns[0].width : colField[cCnt] ?
                                                this.setSavedWidth(colField[cCnt].valueSort
                                                    .levelName, colWidth) : this.resColWidth,
                                            minWidth: 30,
                                            allowReordering: (this.parent.showGroupingBar ? false : this.parent.gridSettings.allowReordering),
                                            allowResizing: this.parent.gridSettings.allowResizing,
                                            visible: true,
                                            headerTextAlign: this.parent.enableRtl ? 'Right' : 'Left'
                                        };
                                        innerModel = [this.pivotColumns[splitPos[innerPos]]];
                                    }
                                    this.isAutoFitEnabled = this.isAutoFitEnabled ? true : autoFitApplied;
                                    tmpSpan = tmpSpan - headerSplit[innerPos];
                                    innerPos = innerPos + headerSplit[innerPos];
                                }
                                columnModel[actualCnt].columns = innerModel;
                            }
                            Eif (columnModel[actualCnt]) {
                                columnModel[actualCnt].clipMode = this.gridSettings.clipMode;
                            }
                            headerSplit[cCnt] = colSpan;
                            splitPos[cCnt] = actualCnt;
                            actualCnt++;
                            cCnt = cCnt + colSpan - 1;
                        }
                    }
                    this.pivotColumns = columnModel.length > 0 ? columnModel : this.pivotColumns;
                } while (headerCnt > 0);
                this.pivotColumns[0] = {
                    field: (0 + '.formattedText'),
                    width: (autoFitApplied && !refreshColumn && !this.parent.isEmptyGrid && pivotColumns[0].autoFit)
                        ? gridColumns[0].width : this.resColWidth,
                    minWidth: 30,
                    headerText: '',
                    allowReordering: false,
                    allowResizing: this.parent.gridSettings.allowResizing,
                    visible: true,
                    clipMode: this.parent.gridSettings.clipMode
                };
            }
            else {
                this.pivotColumns = this.frameEmptyColumns();
            }
            if (this.parent.toolbarModule && this.parent.showToolbar) {
                this.parent.toolbarModule.isReportChange = false;
            }
            this.parent.triggerColumnRenderEvent(this.pivotColumns);
            autoFitApplied = this.parent.pivotColumns.length > 0 && this.parent.pivotColumns[this.parent.pivotColumns.length - 1].autoFit;
            return this.pivotColumns;
        };
        Render.prototype.setSavedWidth = function (column, width) {
            Iif (column === '0.formattedText' && !ej2_base_1.isNullOrUndefined(this.parent.resizedValue)) {
                width = this.parent.resizedValue;
            }
            else {
                width = this.parent.resizeInfo[column] ? this.parent.resizeInfo[column] : width;
            }
            return width;
        };
        Render.prototype.frameEmptyColumns = function () {
            var columns = [];
            var colWidth = this.calculateColWidth(2);
            columns.push({ field: '0.formattedText', headerText: '', minWidth: 30, width: this.resColWidth });
            columns.push({ field: '1.formattedText', headerText: this.parent.localeObj.getConstant('grandTotal'), minWidth: 30, width: colWidth - 3 });
            return columns;
        };
        Render.prototype.getFormatList = function () {
            var formatArray = {};
            for (var vCnt = 0; vCnt < this.parent.dataSourceSettings.values.length; vCnt++) {
                var field = this.parent.dataSourceSettings.values[vCnt];
                var format = 'N';
                if (this.parent.dataType === 'olap') {
                    if (this.parent.olapEngineModule.fieldList[field.name] &&
                        !ej2_base_1.isNullOrUndefined(this.parent.olapEngineModule.fieldList[field.name].formatString)) {
                        var fString = this.parent.olapEngineModule.formatFields[field.name] ?
                            this.parent.olapEngineModule.formatFields[field.name].format :
                            this.parent.olapEngineModule.fieldList[field.name].formatString;
                        fString = (fString === 'Standard') ? 'Number' : fString;
                        format = (fString.indexOf('#') > -1 || fString.match(/\d/) !== null) ? fString : (fString[0] + '2');
                    }
                }
                else {
                    if ((['PercentageOfDifferenceFrom', 'PercentageOfRowTotal', 'PercentageOfColumnTotal', 'PercentageOfGrandTotal', 'PercentageOfParentRowTotal', 'PercentageOfParentColumnTotal', 'PercentageOfParentTotal']).indexOf(field.type) > -1) {
                        format = 'P2';
                    }
                    else if (['PopulationStDev', 'SampleStDev', 'PopulationVar', 'SampleVar', 'Index'].indexOf(field.type) > -1) {
                        format = undefined;
                    }
                    if (this.parent.dataSourceSettings.formatSettings.length > 0) {
                        for (var fCnt = 0; fCnt < this.parent.dataSourceSettings.formatSettings.length; fCnt++) {
                            var formatSettings = this.parent.dataSourceSettings.formatSettings[fCnt];
                            if (field.name === formatSettings.name) {
                                format = formatSettings.format;
                                break;
                            }
                            else {
                                continue;
                            }
                        }
                    }
                }
                formatArray[field.name] = format;
            }
            return formatArray;
        };
        Render.prototype.getValidHeader = function (args, axis) {
            var values = this.parent.dataSourceSettings.values;
            var cellValue;
            if (axis === 'row') {
                var cellInfo = args;
                Eif (this.parent.dataSourceSettings.rows.length === 0 || this.parent.dataSourceSettings.columns.length === 0) {
                    if (this.parent.dataSourceSettings.rows.length === 0 && this.parent.dataSourceSettings.valueAxis === 'row' && (this.parent.localeObj.getConstant('grandTotal') +
                        this.parent.dataSourceSettings.valueSortSettings.headerDelimiter + cellInfo.value)
                        === cellInfo.data[0].valueSort.levelName) {
                        return this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(this.parent.engineModule.fieldList[cellInfo.value.toString()].aggregateType)
                            + ' ' + this.parent.localeObj.getConstant('of') + ' ' + cellInfo.value.toString();
                    }
                    else if (values.length === 1 && this.parent.dataSourceSettings.rows.length === 0) {
                        return this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(values[values.length - 1].type)
                            + ' ' + this.parent.localeObj.getConstant('of') + ' ' + (!ej2_base_1.isNullOrUndefined(values[values.length - 1].caption) ? values[values.length - 1].caption : values[values.length - 1].name);
                    }
                }
                cellValue = cellInfo.value;
            }
            else Eif (axis === 'column') {
                var cellInfo = args;
                Eif (this.parent.dataSourceSettings.rows.length === 0 || this.parent.dataSourceSettings.columns.length === 0) {
                    Iif (!ej2_base_1.isNullOrUndefined(args
                        .gridCell.column.customAttributes) && this.parent.dataSourceSettings.columns.length === 0 &&
                        this.parent.dataSourceSettings.valueAxis === 'column' && (this.parent.localeObj.getConstant('grandTotal') +
                        this.parent.dataSourceSettings.valueSortSettings.headerDelimiter + cellInfo.gridCell.column
                        .customAttributes.cell.formattedText) === cellInfo.gridCell.column
                        .customAttributes.cell.valueSort.levelName) {
                        return this.parent.localeObj.getConstant('total') + ' ' + this.parent.localeObj.getConstant(this.parent.engineModule
                            .fieldList[cellInfo.gridCell.column.customAttributes.cell.actualText]
                            .aggregateType) + ' ' + this.parent.localeObj.getConstant('of') + ' ' + cellInfo.gridCell
                            .column.customAttributes.cell.formattedText;
                    }
                }
                cellValue = cellInfo.cell.value;
            }
            return cellValue;
        };
        Render.prototype.excelColumnEvent = function (args) {
            Iif (this.parent.dataSourceSettings.columns.length === 0 && this.parent.dataSourceSettings.valueAxis === 'column') {
                args.cell.value = this.getValidHeader(args, 'column');
            }
            Iif (args.gridCell !== undefined && args.gridCell.column.width === 'auto') {
                this.parent.lastColumn = args.gridCell.column;
                args.gridCell.column.width = args.gridCell.column.minWidth;
            }
            args = this.exportHeaderEvent(args, 'XLSX');
            this.parent.trigger(events.excelHeaderQueryCellInfo, args);
        };
        Render.prototype.pdfColumnEvent = function (args) {
            if (this.parent.dataSourceSettings.columns.length === 0 && this.parent.dataSourceSettings.valueAxis === 'column') {
                args.cell.value = this.getValidHeader(args, 'column');
            }
            Iif (args.gridCell !== undefined && args.gridCell.column.width === 'auto') {
                this.parent.lastColumn = args.gridCell.column;
                args.gridCell.column.width = args.gridCell.column.minWidth;
            }
            this.parent.trigger(events.pdfHeaderQueryCellInfo, args);
        };
        Render.prototype.excelRowEvent = function (args) {
            var pivotValue;
            if (args.column.field === '0.formattedText') {
                var cell = args.data[0];
                var isValueCell = cell.type && cell.type === 'value';
                var level = 0;
                Iif (this.parent.dataType === 'olap') {
                    level = this.indentCollection[cell.rowIndex];
                }
                else {
                    var levelName = cell.valueSort ? cell.valueSort.levelName.toString() : '';
                    var memberPos = cell.actualText ?
                        cell.actualText.toString().split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length : 0;
                    var levelPosition = levelName.split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length -
                        (memberPos ? memberPos - 1 : memberPos);
                    level = levelPosition ? (levelPosition - 1) : 0;
                }
                this.colPos = 0;
                args.style = { hAlign: 'Left', indent: level * 2 };
                this.lastSpan = isValueCell ? this.lastSpan : level;
            }
            else {
                this.colPos++;
                pivotValue = (args.data)[args.column.customAttributes.cell ?
                    args.column.customAttributes.cell.colIndex : this.colPos];
                Iif (ej2_base_1.isNullOrUndefined(pivotValue.value) || ej2_base_1.isNullOrUndefined(pivotValue.formattedText) || pivotValue.formattedText === '') {
                    args.value = this.parent.exportType === 'Excel' ? null : '';
                }
                else {
                    var aggMatrix = this.parent.dataType === 'pivot' && this.parent.engineModule ? this.parent.engineModule.aggregatedValueMatrix : undefined;
                    Iif (aggMatrix && aggMatrix[pivotValue.rowIndex] && aggMatrix[pivotValue.rowIndex][pivotValue.colIndex]) {
                        args.value = aggMatrix[pivotValue.rowIndex][pivotValue.colIndex];
                    }
                    else {
                        args.value = !ej2_base_1.isNullOrUndefined(pivotValue.value) ? (pivotValue.formattedText === '#DIV/0!' ? pivotValue.formattedText : pivotValue.value) : pivotValue.formattedText;
                    }
                }
            }
            args = this.exportContentEvent(args);
            Iif (this.parent.dataSourceSettings.rows.length === 0 && this.parent.dataSourceSettings.valueAxis === 'row') {
                args.value = args.column.field === '0.formattedText' ? this.getValidHeader(args, 'row')
                    : args.value;
            }
            this.parent.trigger(events.excelQueryCellInfo, args);
            if (pivotValue) {
                Iif (args.style && this.formatList[pivotValue.actualText]) {
                    args.style.type = 'number';
                    args.style.numberFormat = args.style.numberFormat ? args.style.numberFormat : this.formatList[pivotValue.actualText];
                }
                args.column.format = this.formatList[pivotValue.actualText];
            }
        };
        Render.prototype.pdfRowEvent = function (args) {
            args = this.exportContentEvent(args);
            if (args.column.field === '0.formattedText') {
                var level = 0;
                var cell = args.data[0];
                var isValueCell = cell.type && cell.type === 'value';
                Iif (this.parent.dataType === 'olap') {
                    level = this.indentCollection[cell.rowIndex];
                }
                else {
                    var levelName = cell.valueSort ? cell.valueSort.levelName.toString() : '';
                    var memberPos = cell.actualText ?
                        cell.actualText.toString().split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length : 0;
                    var levelPosition = levelName.split(this.parent.dataSourceSettings.valueSortSettings.headerDelimiter).length -
                        (memberPos ? memberPos - 1 : memberPos);
                    level = levelPosition ? (levelPosition - 1) : 0;
                }
                args.style = { paragraphIndent: level * 10 };
                this.lastSpan = isValueCell ? this.lastSpan : level;
                if (this.parent.dataSourceSettings.rows.length === 0 && this.parent.dataSourceSettings.valueAxis === 'row') {
                    args.value = this.getValidHeader(args, 'row');
                }
            }
            this.parent.trigger(events.pdfQueryCellInfo, args);
        };
        Render.prototype.excelDataBound = function (args) {
            var excelRows = args.excelRows;
            var rowStartPos = Object.keys(this.engine.headerContent).length;
            for (var i = 0; i < rowStartPos; i++) {
                var cells = excelRows[i].cells;
                var tmpCell = [];
                for (var j = 0; j < cells.length; j++) {
                    Eif (cells[j].rowSpan !== -1) {
                        tmpCell.push(cells[j]);
                    }
                }
                excelRows[i].cells = tmpCell;
            }
        };
        Render.prototype.exportHeaderEvent = function (args, exportType) {
            var rowSpan = 1;
            if (args.gridCell.column.customAttributes) {
                var cell = args.gridCell.column.customAttributes.cell;
                rowSpan = cell.rowSpan > 0 ? cell.rowSpan : 1;
                Eif (exportType === 'XLSX') {
                    if (cell.rowSpan > 0) {
                        rowSpan = cell.rowSpan;
                    }
                    else if (!ej2_base_1.isNullOrUndefined(cell.type) && cell.level !== 0) {
                        rowSpan = 1;
                        args.cell.rowSpan = 1;
                    }
                }
                this.actualText = cell.actualText;
            }
            else {
                rowSpan = Object.keys(this.engine.headerContent).length;
            }
            if (args.cell.rowSpan !== rowSpan && rowSpan > 0) {
                args.cell.rowSpan = rowSpan;
            }
            return args;
        };
        Render.prototype.frameGridDataSource = function (actualData) {
            var framedDataSource = [];
            for (var i = 0; i < actualData.length; i++) {
                var keyPos = 0;
                framedDataSource[i] = {};
                var keys = Object.keys(actualData[i]);
                for (var j = 0; actualData[i] != null && j < keys.length; j++) {
                    while (keyPos < keys.length) {
                        framedDataSource[i][Number(keys[keyPos])] =
                            this.cloneDataWithoutIndex(actualData[i][Number(keys[keyPos])]);
                        keyPos++;
                    }
                }
            }
            return framedDataSource;
        };
        Render.prototype.cloneDataWithoutIndex = function (data) {
            if (!ej2_base_1.isNullOrUndefined(data)) {
                var keys = Object.keys(data);
                var keyPos = 0;
                var clonedData = {};
                while (keyPos < keys.length) {
                    if (keys[keyPos] !== 'indexObject' && keys[keyPos] !== 'index') {
                        clonedData[keys[keyPos]] = data[keys[keyPos]];
                    }
                    keyPos++;
                }
                return clonedData;
            }
            return data;
        };
        Render.prototype.exportContentEvent = function (args) {
            var cell = args.data[Number(args.column.field.split('.formattedText')[0])];
            args.value = cell.type === 'grand sum' ? (ej2_base_1.isNullOrUndefined(cell.valueSort.axis) ?
                this.parent.localeObj.getConstant('grandTotal') : cell.formattedText) : args.value;
            return args;
        };
        Render.prototype.unWireEvents = function (cell) {
            if (cell.querySelector('.e-hyperlinkcell')) {
                ej2_base_1.EventHandler.remove(cell.querySelector('.e-hyperlinkcell'), this.parent.isAdaptive ? 'touchend' : 'click', this.onHyperCellClick);
            }
            else {
                return;
            }
        };
        Render.prototype.wireEvents = function (cell) {
            if (cell.querySelector('.e-hyperlinkcell')) {
                ej2_base_1.EventHandler.add(cell.querySelector('.e-hyperlinkcell'), this.parent.isAdaptive ? 'touchend' : 'click', this.onHyperCellClick, this);
            }
            else {
                return;
            }
        };
        return Render;
    }());
    exports.Render = Render;
});