lattice-grid-dash
A Dash component that renders an editable
Lattice Grid over a pandas DataFrame, with cell edits
and selection surfaced back to Python @callbacks.
Phase C2 of the Lattice Grid Python integration (card BACKLOG-0000972,
release 1.41). Built on the same shared serialization layer as the Jupyter widget
(phase C1): lattice-grid-pandas.
How it works
The component does not re-implement a React binding for the grid. It consumes
the grid's shipped React adapter (@toclocoinc/lattice-grid/modules/react,
grid v1.40.0), which exposes createLatticeGrid({ React, createGrid }). We feed
it Dash's own React (aliased at bundle time to the global the dash-renderer
serves) so there is a single React instance on the page. This is the lowest-risk
path identified in the spike: the grid team owns and versions the adapter.
DataFrame ──dataframe_to_data()──▶ data prop (columnar, from lattice-grid-pandas)
│
LatticeGrid (React adapter → createGrid)
│ manual edit
cellChanged prop ◀──setProps── onCellChanged (adapter callback)
│
Python @callback(Input("grid", "cellChanged"))
Install
pip install lattice-grid-dash
(Editable/dev: pip install -e packages/lattice-grid-dash. The built JS bundle is
committed under lattice_grid_dash/; rebuild it with npm install && npm run build.)
Usage
import pandas as pd
from dash import Dash, Input, Output, callback, html
import lattice_grid_dash
from lattice_grid_dash import dataframe_to_data, apply_cell_edit
df = pd.DataFrame({"name": ["Ada", "Grace"], "score": [91, 88], "active": [True, False]})
app = Dash(__name__)
app.layout = html.Div([
lattice_grid_dash.LatticeGrid(id="grid", data=dataframe_to_data(df)),
html.Pre(id="out"),
])
@callback(Output("out", "children"), Input("grid", "cellChanged"))
def on_edit(edit):
if not edit:
return "no edits yet"
apply_cell_edit(df, edit) # keep the server-side DataFrame in sync, typed
return f"{edit['colId']} @ row {edit['key']} = {edit['value']}"
if __name__ == "__main__":
app.run(debug=True)
See examples/app.py.
Props
| Prop | Direction | Description |
|---|---|---|
data |
in | DataFrame-derived columnar payload from dataframe_to_data(df): {columns, rowKey, columnar}. Rows are reconstructed and virtualized in the browser. |
columns |
in | Optional explicit column defs (overrides data.columns). |
options |
in | Passthrough to createGrid (e.g. {"edit": True, "rowHeight": 32}). |
licence |
in | Lattice Grid licence key. Empty on localhost → free/unwatermarked. |
cellChanged |
out | Last manual edit {key, colId, value, old, ts}. Drives Python callbacks. |
selectedKeys |
in/out | Selected row keys; set by the grid, settable from Python. |
licenceState |
out | Grid's resolved licence state (e.g. "localhost"). |
style, className |
in | Host element styling. |
Licence plumbing
The licence prop is a single opaque string handed straight to
createGrid({ licence }); the grid resolves it client-side (localhost origins
run free, unwatermarked, with no key). The resolved state is surfaced back on the
licenceState prop. This is the same contract as the Jupyter widget — the shared
rules live in lattice_grid_pandas._grid.
Grid delivery: vendored (default) vs CDN
The grid JavaScript can reach the browser two ways. This package implements the vendored path; the CDN path is documented here for operators who prefer it.
Vendored (implemented)
npm run build bundles the grid core + React adapter into
lattice_grid_dash/lattice_grid_dash.min.js (~2.7 MB) via esbuild, and the grid
CSS is vendored as lattice_grid_dash/lattice-grid.min.css. Both are registered
as Dash assets (_js_dist / _css_dist), so the component works fully offline
— no network at render time. This mirrors the C1 widget's offline=True default
and is what the browser smoke test exercises.
Rebuild:
cd packages/lattice-grid-dash
npm install
npm run build # build:js (esbuild) + build:py (dash-generate-components)
CDN (documented alternative)
To ship a thin component bundle that loads the grid from jsDelivr at render time (smaller wheel, needs network + a relaxed CSP):
- In
build.mjs, mark the grid packages external:external: ['react-dom', '@toclocoinc/lattice-grid', '@toclocoinc/lattice-grid/modules/react']. - Before the bundle loads, inject the grid from the CDN, e.g.
https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.40.0/lattice-grid.esm.min.jsand.../modules/react.esm.min.js(URLs available fromlattice_grid_pandas.cdn_urls()), and add the stylesheet.../lattice-grid.min.css. - Drop the vendored files from
_js_dist/_css_dist.
The two are mutually exclusive; pick one per build.
Development / build toolchain
npm run build:js—esbuildbundlessrc/lib/bundle.js→lattice_grid_dash/lattice_grid_dash.min.js.reactis aliased to Dash's global React (src/lib/react-shim.js); react/react-dom are never bundled.npm run build:py—dash-generate-components(react-docgen v5) readssrc/lib/components/LatticeGrid.react.jsand generatesLatticeGrid.py,_imports_.py, andmetadata.json.pytest tests/— unit tests for the data bridge, plus a real-browser Playwright smoke test (system Chrome viachannel='chrome').
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lattice_grid_dash-0.1.0.tar.gz.
File metadata
- Download URL: lattice_grid_dash-0.1.0.tar.gz
- Upload date:
- Size: 767.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f30826202508618a65ca985a3865e2738ff1d30db0a9494a1765638daeed2a39
|
|
| MD5 |
0c8d23c202d329adad08842bb9df7ea2
|
|
| BLAKE2b-256 |
7c8184fea16a4de0ccb32fe210d3f0e19c52361e28182b21ef63ced08aa31726
|
Provenance
The following attestation bundles were made for lattice_grid_dash-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on toclocoinc/lattice-grid-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lattice_grid_dash-0.1.0.tar.gz -
Subject digest:
f30826202508618a65ca985a3865e2738ff1d30db0a9494a1765638daeed2a39 - Sigstore transparency entry: 2751949922
- Sigstore integration time:
-
Permalink:
toclocoinc/lattice-grid-python@413eab2e38be795ed6bbd325b7a14e411faa35cf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/toclocoinc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@413eab2e38be795ed6bbd325b7a14e411faa35cf -
Trigger Event:
push
-
Statement type:
File details
Details for the file lattice_grid_dash-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lattice_grid_dash-0.1.0-py3-none-any.whl
- Upload date:
- Size: 768.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c9f8292ff92bdd530f7f4676b7cd04dd248dc22239f07157832af489a5eaf99
|
|
| MD5 |
81beb0730a83feb1ce207e0a80d15745
|
|
| BLAKE2b-256 |
a395b992426a1ee825cc9f231c1e6c62d2a6dab723078d80eb4c4cff63964050
|
Provenance
The following attestation bundles were made for lattice_grid_dash-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on toclocoinc/lattice-grid-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lattice_grid_dash-0.1.0-py3-none-any.whl -
Subject digest:
9c9f8292ff92bdd530f7f4676b7cd04dd248dc22239f07157832af489a5eaf99 - Sigstore transparency entry: 2751949949
- Sigstore integration time:
-
Permalink:
toclocoinc/lattice-grid-python@413eab2e38be795ed6bbd325b7a14e411faa35cf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/toclocoinc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@413eab2e38be795ed6bbd325b7a14e411faa35cf -
Trigger Event:
push
-
Statement type: