• Edit
  • Download
  • <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingGrid: Docs Getting Started</title>
      <!--Script Reference[1]-->
      <script src="https://cdn.zinggrid.com/zinggrid.min.js" defer></script>
      <style>
        zing-grid[loading] {
          height: 128px;
        }
      </style>
    </head>
    
    <body>
      <!--Grid Component Placement[2]-->
      <zing-grid caption="Data HTML Attribute Assignment" sort search layout="row" viewport-stop>
      </zing-grid>
      <script>
        // window.onload event for Javascript to run after HTML
        // because this Javascript is injected into the document head
        window.addEventListener('load', () => {
          // content after DOM load
          const zgRef = document.querySelector('zing-grid');
          const data = [{
              name: 'Philip J. Fry',
              origin: 'Earth',
            },
            {
              name: 'Turanga Leela',
              origin: 'Earth',
            },
            {
              name: 'Bender Bending Rodriguez',
              origin: 'Earth',
            },
            {
              name: 'Amy Wong',
              origin: 'Mars',
            },
            {
              name: 'Doctor John Zoidberg',
              origin: 'Decapod 10',
            },
            {
              name: 'Lord Nibbler',
              origin: 'Earth',
            }
          ];
          zgRef.setAttribute('data', JSON.stringify(data));
        });
      </script>
    </body>
    
    </html>
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>ZingGrid: Docs Getting Started</title>
        <!--Script Reference[1]-->
        <script src="https://cdn.zinggrid.com/zinggrid.min.js" defer></script>
      </head>
      <body>
        <!--Grid Component Placement[2]-->
        <zing-grid 
          caption="Data HTML Attribute Assignment"
          sort
          search
          layout="row"
          viewport-stop>
        </zing-grid>
      </body>
    </html>
    
          
    // window.onload event for Javascript to run after HTML
    // because this Javascript is injected into the document head
    window.addEventListener('load', () => {
      // content after DOM load
      const zgRef = document.querySelector('zing-grid');
      const data = [
        {
          name: 'Philip J. Fry',
          origin: 'Earth',
        },
        {
          name: 'Turanga Leela',
          origin: 'Earth',
        },
        {
          name: 'Bender Bending Rodriguez',
          origin: 'Earth',
        },
        {
          name: 'Amy Wong',
          origin: 'Mars',
        },
        {
          name: 'Doctor John Zoidberg',
          origin: 'Decapod 10',
        },
        {
          name: 'Lord Nibbler',
          origin: 'Earth',
        }
      ]; 
      zgRef.setAttribute('data', JSON.stringify(data));
    });