• Edit
  • Download
  • <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingGrid Demo</title>
      <script nonce="undefined" src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
      <style>
        html,
        body {
          height: 100%;
          width: 100%;
          margin: 0;
          padding: 0;
        }
    
        zing-grid[loading] {
          height: 165px;
        }
      </style>
    </head>
    
    <body>
      <zing-grid>
        <zg-colgroup>
          <!-- Toggles through two values -->
          <zg-column index="boolean" type="toggle" type-toggle-options='["true","false"]'></zg-column>
    
          <!-- Toggles with two+ values requires renderer -->
          <zg-column index="suite" type="toggle" renderer="render_suite" type-toggle-options='["♣","♦","♥","♠"]'></zg-column>
    
          <!--  Uses the render_color method to display the proper item with many toggle options -->
          <zg-column index="color" type="toggle" renderer="render_color" type-toggle-options='["red", "orange", "yellow", "green", "blue"]'></zg-column>
        </zg-colgroup>
        <zg-data data='[
            {
              "boolean": true,
              "suite": "♣",
              "color": "red"
            }, {
              "boolean": false,
              "suite": "♥",
              "color": "blue"
            }
          ]'></zg-data>
      </zing-grid>
      <script>
        ZingGrid.setLicense(['26ccbfec16b8be9ee98c7d57bee6e498']);
        window.render_suite = (curVal, $cell) => {
          return curVal;
        };
    
        window.render_color = (curVal, $cell) => {
          return `<img src="https://storage.googleapis.com/zg-demos.appspot.com/toggle_column/${curVal}.png" width="25px" height="25px">`;
        };
      </script>
    </body>
    
    </html>
    <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingGrid Demo</title>
      <script src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
    </head>
    
    <body>
      <zing-grid>
        <zg-colgroup>
          <!-- Toggles through two values -->
          <zg-column index="boolean" type="toggle" type-toggle-options='["true","false"]'></zg-column>
    
          <!-- Toggles with two+ values requires renderer -->
          <zg-column index="suite" type="toggle" renderer="render_suite" type-toggle-options='["♣","♦","♥","♠"]'></zg-column>
    
          <!--  Uses the render_color method to display the proper item with many toggle options -->
          <zg-column index="color" type="toggle" renderer="render_color" type-toggle-options='["red", "orange", "yellow", "green", "blue"]'></zg-column>
        </zg-colgroup>
        <zg-data data='[
            {
              "boolean": true,
              "suite": "♣",
              "color": "red"
            }, {
              "boolean": false,
              "suite": "♥",
              "color": "blue"
            }
          ]'></zg-data>
      </zing-grid>
    </body>
    
    </html>
    html,
    body {
      height: 100%;
      width: 100%;
      margin: 0;
      padding: 0;
    }
    window.render_suite = (curVal, $cell) => {
      return curVal;
    };
    
    window.render_color = (curVal, $cell) => {
      return `<img src="https://storage.googleapis.com/zg-demos.appspot.com/toggle_column/${curVal}.png" width="25px" height="25px">`;
    };