Lattice Grid Buy a licence

developer guide

Using <lattice-grid> as a custom element

One script, one tag, no build step. For Rails, Django, Laravel or any page without a bundler.

One script, one tag

The web component is a self-contained module that registers a custom element when it loads. Add the stylesheet and the module, then write the tag. Scalar settings go on as attributes; columns and rows can be JSON attributes for a small static grid.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.13.0/lattice-grid.min.css">
<script type="module" src="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.13.0/modules/webcomponent.esm.min.js"></script>

<lattice-grid
  row-key="id"
  columns='[{"field":"circuit","title":"Circuit"},{"field":"charge","title":"Charge","type":"number"}]'
  rows='[{"id":1,"circuit":"ETH-LON-1","charge":465.32}]'
></lattice-grid>

Attributes for scalars, properties for data

A JSON attribute is fine for a handful of rows, but real data goes on as a property, which carries a live value rather than a string the element has to parse. The grid instance is on .grid once the element has upgraded, so the whole public API is one property away.

const el = document.querySelector('lattice-grid');

// Structured values go on as properties, not attributes.
el.columns = columns;
el.rows = rows;

// The real grid instance is on .grid once the element has upgraded.
el.grid.export.csv({ download: true });

It carries the grid inside it

When to reach for it

Reach for the element on a page that has no bundler, a server-rendered template from Rails, Django or Laravel, a CMS block, a plain HTML file, where an import is not available and a script tag is. On a page that already bundles, the base build or a framework adapter is lighter, because it does not ship a second copy of the grid.

See the web component demo and the developer guide.