• Edit
  • Download
    1. <!DOCTYPE html>
    2. <html class="zg-html">
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingGrid Demo</title>
    7. <script nonce="undefined" src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
    8. <style>
    9. .zg-html,
    10. .zg-body {
    11. height: 100%;
    12. width: 100%;
    13. margin: 0;
    14. padding: 0;
    15. }
    16.  
    17. zing-grid[loading] {
    18. height: 450px;
    19. }
    20. </style>
    21. </head>
    22.  
    23. <body class="zg-body">
    24. <zing-grid caption="Fortune 500 Companies">
    25. <zg-data data='[
    26. {
    27. "company": "Walmart",
    28. "stockPrice": 84.54,
    29. "quarterlySales": [123.18, 136.27, null, null],
    30. "priceSuffix": "Billions"
    31. },
    32. {
    33. "company": "Berkshire Hathaway",
    34. "stockPrice": 298300,
    35. "quarterlySales": [133.18, 136.27, null, null],
    36. "priceSuffix": "Billions"
    37. },
    38. {
    39. "company": "Apple",
    40. "stockPrice": 184.22,
    41. "quarterlySales": [153.68, 116.62, null, null],
    42. "priceSuffix": "Billions"
    43. },
    44. {
    45. "company": "Exxon Mobil",
    46. "stockPrice": 84.54,
    47. "quarterlySales": [123.18, 136.27, null, null],
    48. "priceSuffix": "Billions"
    49. }
    50. ]'></zg-data>
    51. <zg-colgroup>
    52. <zg-column index="company"></zg-column>
    53. <zg-column index="stockPrice" type="currency"></zg-column>
    54. <zg-column index="quarterlySales" renderer="_renderInnerGrid" width="70%">
    55. <template>
    56. <zing-grid caption="[[record.company]] 2018 Sales in
    57. [[record.priceSuffix]]">
    58. <zg-colgroup>
    59. <zg-column index="q1"></zg-column>
    60. <zg-column index="q2"></zg-column>
    61. <zg-column index="q3"></zg-column>
    62. <zg-column index="q4"></zg-column>
    63. </zg-colgroup>
    64. </zing-grid>
    65. </template>
    66. </zg-column>
    67. </zg-colgroup>
    68. </zing-grid>
    69. <script>
    70. ZingGrid.setLicense(['26ccbfec16b8be9ee98c7d57bee6e498']);
    71.  
    72. function _renderInnerGrid(quarterlySales, cellRef, $cell) {
    73. let data = [{
    74. q1: quarterlySales[0],
    75. q2: quarterlySales[1],
    76. q3: quarterlySales[2] || 'N/A',
    77. q4: quarterlySales[3] || 'N/A',
    78. }];
    79. cellRef.querySelector('zing-grid').setData(data);
    80. }
    81. </script>
    82. </body>
    83.  
    84. </html>
    1. <!DOCTYPE html>
    2. <html class="zg-html">
    3.  
    4. <head>
    5. <meta charset="utf-8">
    6. <title>ZingGrid Demo</title>
    7. <script src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
    8. </head>
    9.  
    10. <body class="zg-body">
    11. <zing-grid caption="Fortune 500 Companies">
    12. <zg-data data='[
    13. {
    14. "company": "Walmart",
    15. "stockPrice": 84.54,
    16. "quarterlySales": [123.18, 136.27, null, null],
    17. "priceSuffix": "Billions"
    18. },
    19. {
    20. "company": "Berkshire Hathaway",
    21. "stockPrice": 298300,
    22. "quarterlySales": [133.18, 136.27, null, null],
    23. "priceSuffix": "Billions"
    24. },
    25. {
    26. "company": "Apple",
    27. "stockPrice": 184.22,
    28. "quarterlySales": [153.68, 116.62, null, null],
    29. "priceSuffix": "Billions"
    30. },
    31. {
    32. "company": "Exxon Mobil",
    33. "stockPrice": 84.54,
    34. "quarterlySales": [123.18, 136.27, null, null],
    35. "priceSuffix": "Billions"
    36. }
    37. ]'></zg-data>
    38. <zg-colgroup>
    39. <zg-column index="company"></zg-column>
    40. <zg-column index="stockPrice" type="currency"></zg-column>
    41. <zg-column index="quarterlySales" renderer="_renderInnerGrid" width="70%">
    42. <template>
    43. <zing-grid caption="[[record.company]] 2018 Sales in
    44. [[record.priceSuffix]]">
    45. <zg-colgroup>
    46. <zg-column index="q1"></zg-column>
    47. <zg-column index="q2"></zg-column>
    48. <zg-column index="q3"></zg-column>
    49. <zg-column index="q4"></zg-column>
    50. </zg-colgroup>
    51. </zing-grid>
    52. </template>
    53. </zg-column>
    54. </zg-colgroup>
    55. </zing-grid>
    56. </body>
    57.  
    58. </html>
    1. .zg-html,
    2. .zg-body {
    3. height: 100%;
    4. width: 100%;
    5. margin: 0;
    6. padding: 0;
    7. }
    1. function _renderInnerGrid(quarterlySales, cellRef, $cell) {
    2. let data = [{
    3. q1: quarterlySales[0],
    4. q2: quarterlySales[1],
    5. q3: quarterlySales[2] || 'N/A',
    6. q4: quarterlySales[3] || 'N/A',
    7. }];
    8. cellRef.querySelector('zing-grid').setData(data);
    9. }