Lattice Grid Buy a licence

demo D229

Pushdown to a live OData service

A grid over the public Northwind service; filter and sort are pushed to it, and lastPlan shows the split

createPushdownSource · odataAdapter · lastPlan()

Building…
Loading a live grid…

The configuration

<script>
  import * as LatticeGrid from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.esm.min.js';
  import createLatticeAction from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/modules/svelte.esm.min.js';

  const { createGrid, odataAdapter, createPushdownSource } = LatticeGrid;
  const lattice = createLatticeAction({ createGrid });

  // The adapter takes a URL and imports nothing. createPushdownSource turns the
  // grid's query into an OData request and finishes any residual in the grid.
  const adapter = odataAdapter({
    url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Orders',
  });
  const source = createPushdownSource({
    adapter,
    compute: LatticeGrid,   // the grid's own kernels, for anything the service could not do
    pageSize: 100,
  });

  const config = {
    rowKey: 'OrderID',
    toolPanel: { side: 'left', panels: ['filters', 'columns'] },
    columns: [
      { field: 'OrderID', title: 'Order', type: 'number' },
      { field: 'CustomerID', title: 'Customer', filter: { type: 'set' } },
      { field: 'ShipCountry', title: 'Ship to', filter: { type: 'set' } },
      { field: 'Freight', title: 'Freight', type: 'number' },
      { field: 'OrderDate', title: 'Ordered', type: 'dateString' },
    ],
    source,
    // onGrid hands over the live grid the moment it is created. After each query,
    // lastPlan() reports what the service ran and what stayed here.
    onGrid: (grid) => {
      grid.on('rows:changed', () => {
        const plan = source.lastPlan();
        if (plan) console.log(plan.unpushed.length ? 'pushed part' : 'pushed all', plan);
      });
    },
  };
</script>

<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.min.css">
</svelte:head>

<div use:lattice={config} style="height: 520px"></div>