• Edit
  • Download
  • <!DOCTYPE html>
    <html class="zc-html">
    
    <head>
      <meta charset="utf-8">
      <title>ZingGrid: Simple Grid</title>
      <script nonce="undefined" src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
      <script nonce="undefined" src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
      <style>
        body {
          background: #e6e6e6;
        }
    
        zing-grid[loading] {
          height: 148px;
        }
      </style>
    </head>
    
    <body>
      <h3>Grid modified to retrieve 15 records in descending order with readCustomFunction ZGParam.</h3>
      <zing-grid caption="SupabaseJS Demo" sort pager>
        <zg-data adapter="supabaseJS">
          <zg-param name="dataTable" value="got_deaths"></zg-param>
          <zg-param name="idKey" value="order"></zg-param>
          <zg-param name="readCustomFunction" value="read"></zg-param>
        </zg-data>
      </zing-grid>
      <script>
        ZingGrid.setLicense(['26ccbfec16b8be9ee98c7d57bee6e498']);
        var __awaiter = (this && this.__awaiter) || function(thisArg, _arguments, P, generator) {
          function adopt(value) {
            return value instanceof P ? value : new P(function(resolve) {
              resolve(value);
            });
          }
          return new(P || (P = Promise))(function(resolve, reject) {
            function fulfilled(value) {
              try {
                step(generator.next(value));
              } catch (e) {
                reject(e);
              }
            }
    
            function rejected(value) {
              try {
                step(generator["throw"](value));
              } catch (e) {
                reject(e);
              }
            }
    
            function step(result) {
              result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
            }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
          });
        };
        const supabaseUrl = 'https://duvwlthndkbzpwewfumt.supabase.co';
        const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1dndsdGhuZGtienB3ZXdmdW10Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTY0MTA5MTQsImV4cCI6MjAzMTk4NjkxNH0.MVDZMwuFA74_ACO9ajP_gErBLc67o6opNxwRW_rde0c';
        const supabaseClient = supabase.createClient(supabaseUrl, supabaseKey);
        ZingGrid.registerClient(supabaseClient);
    
        function read(opt) {
          return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function*() {
            const {
              data,
              error
            } = yield supabaseClient
              .from('got_deaths')
              .select()
              .order('order', {
                ascending: false
              })
              .limit(10);
            opt.callback(data);
          }));
        };
      </script>
    </body>
    
    </html>
    <!DOCTYPE html>
    <html class="zc-html">
    
    <head>
      <meta charset="utf-8">
      <title>ZingGrid: Simple Grid</title>
      <script src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
    </head>
    
    <body>
      <h3>Grid modified to retrieve 15 records in descending order with readCustomFunction ZGParam.</h3>
      <zing-grid caption="SupabaseJS Demo" sort pager>
        <zg-data adapter="supabaseJS">
          <zg-param name="dataTable" value="got_deaths"></zg-param>
          <zg-param name="idKey" value="order"></zg-param>
          <zg-param name="readCustomFunction" value="read"></zg-param>
        </zg-data>
      </zing-grid>
    </body>
    
    </html>
    body {
      background: #e6e6e6;
    }
    var __awaiter = (this && this.__awaiter) || function(thisArg, _arguments, P, generator) {
      function adopt(value) {
        return value instanceof P ? value : new P(function(resolve) {
          resolve(value);
        });
      }
      return new(P || (P = Promise))(function(resolve, reject) {
        function fulfilled(value) {
          try {
            step(generator.next(value));
          } catch (e) {
            reject(e);
          }
        }
    
        function rejected(value) {
          try {
            step(generator["throw"](value));
          } catch (e) {
            reject(e);
          }
        }
    
        function step(result) {
          result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
        }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
      });
    };
    const supabaseUrl = 'https://duvwlthndkbzpwewfumt.supabase.co';
    const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1dndsdGhuZGtienB3ZXdmdW10Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTY0MTA5MTQsImV4cCI6MjAzMTk4NjkxNH0.MVDZMwuFA74_ACO9ajP_gErBLc67o6opNxwRW_rde0c';
    const supabaseClient = supabase.createClient(supabaseUrl, supabaseKey);
    ZingGrid.registerClient(supabaseClient);
    
    function read(opt) {
      return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function*() {
        const {
          data,
          error
        } = yield supabaseClient
          .from('got_deaths')
          .select()
          .order('order', {
            ascending: false
          })
          .limit(10);
        opt.callback(data);
      }));
    };