• Edit
  • Download
  • <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingGrid: filterer demo</title>
      <script nonce="undefined" src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
      <style>
        body {
          background: #e6e6e6;
        }
    
        zing-grid[loading] {
          height: 317px;
        }
      </style>
    </head>
    
    <body>
      <h3>`[filterer]` enables overriding part or all of the filterer for that column.</h3>
      <p>In this example, the filterer has been customized to accept only letter inputs for the "Name" column</p>
    
      <zing-grid filter="inline" filterer>
        <zg-caption>filterer Demo</zg-caption>
        <zg-data data='[
            {
              "name": "Maria",
              "number": 123
            },
            {
              "name": "Juanita",
              "number": 456
            },
            {
              "name": "Felicity",
              "number": 789
            }
          ]'>
        </zg-data>
        <zg-colgroup>
          <zg-column index="name" filterer="customFilter"></zg-column>
          <zg-column index="number"></zg-column>
        </zg-colgroup>
      </zing-grid>
    
      <script>
        ZingGrid.setLicense(['26ccbfec16b8be9ee98c7d57bee6e498']);
        window.customFilter = {
          afterInit(oDOMFilter) {
            let oDOMInput = oDOMFilter.querySelector('input');
            oDOMInput.addEventListener('keypress', (e) => {
              let char = e.key;
              if (!/^[a-z]$/i.test(char)) {
                e.preventDefault();
              };
            });
          }
        };
      </script>
    </body>
    
    </html>
    <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="utf-8">
      <title>ZingGrid: filterer demo</title>
      <script src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
    </head>
    
    <body>
      <h3>`[filterer]` enables overriding part or all of the filterer for that column.</h3>
      <p>In this example, the filterer has been customized to accept only letter inputs for the "Name" column</p>
    
      <zing-grid filter="inline" filterer>
        <zg-caption>filterer Demo</zg-caption>
        <zg-data data='[
            {
              "name": "Maria",
              "number": 123
            },
            {
              "name": "Juanita",
              "number": 456
            },
            {
              "name": "Felicity",
              "number": 789
            }
          ]'>
        </zg-data>
        <zg-colgroup>
          <zg-column index="name" filterer="customFilter"></zg-column>
          <zg-column index="number"></zg-column>
        </zg-colgroup>
      </zing-grid>
    
    </body>
    
    </html>
    body {
      background: #e6e6e6;
    }
    window.customFilter = {
      afterInit(oDOMFilter) {
        let oDOMInput = oDOMFilter.querySelector('input');
        oDOMInput.addEventListener('keypress', (e) => {
          let char = e.key;
          if (!/^[a-z]$/i.test(char)) {
            e.preventDefault();
          };
        });
      }
    };