Playground
A table for rows the server keeps: a sticky header, sorting (on the server, or in the table when it has every row), row selection, and a virtual scroll the server drives. Cells can be links, carry a muted suffix or show as badges; a column picker lets the user hide columns, resizable lets them resize columns, and exports come from the server, which has every row. The table asks for the rows in view (plus a buffer), the server sends that window, and a table of a million rows ships a few hundred of them.
The rows scroll in an sb-virtual-scroll, after the virtual scroll in Anders Murphy's hyperlith. Every row has the same height (row-height), so the scroll position alone tells which rows are in view. When the view comes halfway into the buffer, the table emits sb-window with the rows it wants; until they arrive, the rows it lacks show as placeholders.
Examples
100,000 stars from the server
The first 100,000 stars of the site's made-up star catalog, stored in SQLite so the server can sort them (/demo/data/rows). Scroll, drag the scrollbar to the middle, click a header to sort, pick rows, hide columns, click a star's name, and download the table as CSV or JSON. The page never holds more than a few hundred rows:
- On connect, and whenever the view needs rows it doesn't have, the table emits
sb-windowwith{offset, count}and the order to send them in (key,dir). - A header click emits
sb-sortwith the order asked for (key,dir) and the window to answer with (offset0,count). - Both run
@get('/demo/data/rows?…&into=_stars&cells=rich'), and the server patches$_starswith{rows, offset, total, sort}. Withcells=rich, its rows hold cell objects: the names are links, the distances carry their unit, and stars bright enough to see have a badge on their magnitude. data-attrhands them back. A newsortscrolls to the top. Answers can land out of order: after a header click, the table takes rows only in the order it asked for, and drops late answers in the order it replaced.- A click on a name emits
sb-cell-activate. The page cancels the link and shows the star instead: this is how a cell runs an action on the page. - The CSV and JSON buttons are the page's own, in the
toolbarslot. They callrequestExport(), the table emitssb-exportwith its order, the shown columns and the selection, and the page turns that into a download of/demo/data/rows/export(see Exports). A download link starts no navigation, so the page's streams stay open.
data-indicator sets loading while a request is in flight.
<div data-signals="{_stars: {rows: [], offset: 0, total: 0, sort: {key: '', dir: ''}}, _loading: false, _picked: [], _star: ''}" style="display: grid; gap: 12px">
<sb-data-table label="Star catalog" selection="multiple" column-picker style="block-size: 24rem"
columns='[{"key":"name","label":"Name","sortable":true},{"key":"class","label":"Class","width":"6rem","sortable":true},{"key":"constellation","label":"Constellation","sortable":true},{"key":"distance","label":"Distance","align":"end","sortable":true},{"key":"magnitude","label":"Magnitude","align":"end","width":"7.5rem","sortable":true},{"key":"planets","label":"Planets","align":"end","width":"6rem"}]'
data-attr="{rows: JSON.stringify($_stars.rows), offset: $_stars.offset, total: $_stars.total, sort: JSON.stringify($_stars.sort), loading: $_loading}"
data-preserve-attr="rows offset total sort loading"
data-indicator:_loading
data-on:sb-window="@get('/demo/data/rows?into=_stars&cells=rich&' + new URLSearchParams(evt.detail))"
data-on:sb-sort="@get('/demo/data/rows?into=_stars&cells=rich&' + new URLSearchParams(evt.detail))"
data-on:sb-change="$_picked = evt.detail.value"
data-on:sb-cell-activate="evt.preventDefault(); $_star = evt.detail.value"
data-on:sb-export="Object.assign(document.createElement('a'), {href: '/demo/data/rows/export?' + new URLSearchParams({format: evt.detail.format, key: evt.detail.sort.key, dir: evt.detail.sort.dir, columns: evt.detail.columns, selected: evt.detail.selected}), download: ''}).click()">
<button slot="toolbar" data-on:click="el.closest('sb-data-table').requestExport('csv')">CSV</button>
<button slot="toolbar" data-on:click="el.closest('sb-data-table').requestExport('json')">JSON</button>
</sb-data-table>
<span>Selected: <b data-text="$_picked.join(', ') || 'nothing'"></b></span>
<span>Star: <b data-text="$_star || 'click a name'"></b></span>
</div>
Without Datastar signals, the server can also render the element with the first window in its attributes (rows, offset, total, sort) and morph in the next ones. A table that arrives with the rows in view asks for nothing on connect.
A small table
With all rows given and no total, the table has everything and never asks the server. A click on a sortable header sorts the rows right here, and the table still emits sb-sort for a page that wants to keep the choice.
<sb-data-table label="Moons of Jupiter" selection="single" style="inline-size: min(100%, 30rem)"
columns='[{"key":"name","label":"Moon","sortable":true},{"key":"radius","label":"Radius (km)","align":"end","sortable":true},{"key":"found","label":"Found","align":"end","width":"6rem","sortable":true}]'
rows='[{"id":"io","name":"Io","radius":1821.6,"found":1610},{"id":"europa","name":"Europa","radius":1560.8,"found":1610},{"id":"ganymede","name":"Ganymede","radius":2634.1,"found":1610},{"id":"callisto","name":"Callisto","radius":2410.3,"found":1610},{"id":"amalthea","name":"Amalthea","radius":83.5,"found":1892}]'></sb-data-table>
Rich cells
A value can be a cell object instead of a plain value: {"value": 2634.1, "suffix": "km"} shows the number with a muted unit after it and still sorts by the number, href makes the text a link, and tone shows it as a badge. The names link to Wikipedia, and the last row shows that a cell's text is only ever text, never markup:
<sb-data-table label="Moons of Jupiter" selection="single" style="inline-size: min(100%, 34rem)"
columns='[{"key":"name","label":"Moon","sortable":true},{"key":"radius","label":"Radius","align":"end","sortable":true},{"key":"group","label":"Group","width":"7rem","sortable":true}]'
rows='[{"id":"io","name":{"value":"Io","href":"https://en.wikipedia.org/wiki/Io_(moon)"},"radius":{"value":1821.6,"suffix":"km"},"group":{"value":"Galilean","tone":"info"}},{"id":"europa","name":{"value":"Europa","href":"https://en.wikipedia.org/wiki/Europa_(moon)"},"radius":{"value":1560.8,"suffix":"km"},"group":{"value":"Galilean","tone":"info"}},{"id":"ganymede","name":{"value":"Ganymede","href":"https://en.wikipedia.org/wiki/Ganymede_(moon)"},"radius":{"value":2634.1,"suffix":"km"},"group":{"value":"Galilean","tone":"info"}},{"id":"callisto","name":{"value":"Callisto","href":"https://en.wikipedia.org/wiki/Callisto_(moon)"},"radius":{"value":2410.3,"suffix":"km"},"group":{"value":"Galilean","tone":"info"}},{"id":"amalthea","name":{"value":"Amalthea","href":"https://en.wikipedia.org/wiki/Amalthea_(moon)"},"radius":{"value":83.5,"suffix":"km"},"group":{"value":"Inner","tone":"neutral"}},{"id":"test","name":"<b>not bold</b>","radius":{"value":0.5,"suffix":"km"},"group":{"value":"Made up","tone":"warning"}}]'></sb-data-table>
Columns the user picks
With column-picker, a Columns button above the table opens a menu of every column, each with a checkbox. hidden-columns holds the keys of the columns not shown. It is view state, like a tree's expanded branches: the table works without anyone keeping it, and when the user changes it, the table emits sb-columns with the whole list. Here a page signal keeps it:
<div data-signals="{_hidden: ['mass']}" style="display: grid; gap: 12px">
<sb-data-table label="Planets" column-picker style="inline-size: min(100%, 40rem)"
columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end","width":"5rem"},{"key":"radius","label":"Radius","align":"end"},{"key":"mass","label":"Mass (Earths)","align":"end"},{"key":"day","label":"Day","align":"end"}]'
rows='[{"id":"mercury","name":"Mercury","moons":0,"radius":{"value":2439.7,"suffix":"km"},"mass":0.055,"day":{"value":4222.6,"suffix":"h"}},{"id":"venus","name":"Venus","moons":0,"radius":{"value":6051.8,"suffix":"km"},"mass":0.815,"day":{"value":2802,"suffix":"h"}},{"id":"earth","name":"Earth","moons":1,"radius":{"value":6371,"suffix":"km"},"mass":1,"day":{"value":24,"suffix":"h"}},{"id":"mars","name":"Mars","moons":2,"radius":{"value":3389.5,"suffix":"km"},"mass":0.107,"day":{"value":24.7,"suffix":"h"}},{"id":"jupiter","name":"Jupiter","moons":95,"radius":{"value":69911,"suffix":"km"},"mass":317.8,"day":{"value":9.9,"suffix":"h"}}]'
data-attr:hidden-columns="JSON.stringify($_hidden)" data-preserve-attr="hidden-columns"
data-on:sb-columns="$_hidden = evt.detail.hidden"></sb-data-table>
<span>Hidden: <b data-text="$_hidden.join(', ') || 'nothing'"></b></span>
</div>
A server that should remember the choice posts sb-columns as a command and keeps the list as a session preference, so the next page renders it into hidden-columns. A new list from the server wins over the user's, the same list again leaves it alone, and el.hiddenColumns reads or sets the list on the page without an event. At least one column always shows: the menu won't hide the last one, and a list that hides every column still shows the first.
Columns the user resizes
With resizable, each header has a grip at its end: drag it, or double-click it to fit the column. widths holds the user's widths, {key: px}, and the table emits sb-column-widths with the whole map once per change, at the end of a drag. It is view state like hidden-columns, kept here in a page signal as a JSON string: assigning an object to a signal merges into it, and the menu's "Reset column widths" sends {}.
<div data-signals="{_wide: {rows: [], offset: 0, total: 0, fit: {}}, _widths: '{}'}" style="display: grid; gap: 12px">
<sb-data-table label="Star catalog" resizable column-picker style="block-size: 20rem"
data-attr="{columns: JSON.stringify(['name', 'constellation', 'distance', 'magnitude'].map((key) => ({key, fit: $_wide.fit[key]}))), rows: JSON.stringify($_wide.rows), offset: $_wide.offset, total: $_wide.total, widths: $_widths}"
data-preserve-attr="columns rows offset total widths"
data-on:sb-window="@get('/demo/data/rows?into=_wide&cells=rich&' + new URLSearchParams(evt.detail))"
data-on:sb-column-widths="$_widths = JSON.stringify(evt.detail.widths)"></sb-data-table>
<span>Widths: <b data-text="$_widths"></b></span>
</div>
A new widths from the server wins, the same one again keeps the user's, and el.widths reads or sets the map without an event; a server that keeps it posts sb-column-widths as a command, like sb-columns. Widths go by key, so a hidden column has its width again when it shows.
A fit never makes a column narrower than its header. A table that holds only a window can't measure the rest, so the server sends each column's fit for the whole result. Here SQLite finds each column's longest value:
// DemoStarLongest scans the catalog for its longest values.
func (r *Reader) DemoStarLongest(ctx context.Context) (DemoStarLongest, error) {
var l DemoStarLongest
err := r.tx.QueryRowContext(ctx, `SELECT coalesce(max(length(name)), 0), coalesce(max(length(class)), 0), coalesce(max(length(constellation)), 0),
coalesce(max(distance), 0), coalesce(min(magnitude), 0), coalesce(max(magnitude), 0), coalesce(max(planets), 0) FROM demo_stars`).
Scan(&l.Name, &l.Class, &l.Constellation, &l.Distance, &l.MagnitudeMin, &l.MagnitudeMax, &l.Planets)
return l, err
}
demoStarFits turns them into widths at 8.4 px a character, JetBrains Mono's width at 14 px, plus the padding, unit and badge: exact in a monospace font, an estimate in others.
// demoStarFits are sb-data-table's fit widths for the catalog's columns, in
// px: the most characters a column's values take as the table formats them
// (numbers with grouping and up to three decimals), at 8.4 px each, plus the
// cell's padding. The site's table text is JetBrains Mono at 14 px, whose
// every character is 0.6 em wide, so this is exact there and an estimate in
// other fonts. Rich cells add the distance's unit and the magnitude's badge.
func demoStarFits(l queries.DemoStarLongest, rich bool) map[string]int {
const char, em, pad = 8.4, 14.0, 24 + 1
width := func(chars int, extra float64) int { return int(math.Ceil(float64(chars)*char+extra)) + pad }
number := func(v float64) int { // "-12,345.678"
n := len(strconv.Itoa(int(math.Abs(v))))
n += (n-1)/3 + 4
if v < 0 {
n++
}
return n
}
unit, badge := 0.0, 0.0
if rich {
unit, badge = 2*char+0.35*em, 0.8*em+2 // "ly" after a 0.35em margin; a badge's padding and border
}
return map[string]int{
"name": width(l.Name, 0),
"class": width(l.Class, 0),
"constellation": width(l.Constellation, 0),
"distance": width(number(l.Distance), unit),
"magnitude": width(max(number(l.MagnitudeMin), number(l.MagnitudeMax)), badge),
"planets": width(len(strconv.Itoa(l.Planets)), 0),
}
}
Without fit, the table measures the rows at hand.
Server side
The handler behind the first example is Go with the Datastar SDK; any SDK works the same way. It reads the window and the order from the query, and demoAnswer patches the signal named by into (it also serves plain JSON and the demo's delay). The answer carries the order it used, so the header shows what the rows are, not what was clicked. With cells=rich, each star goes through demoStarCells (below, with the export), which turns it into cell objects:
// demoRows answers a table's window and sort requests (sb-data-table's
// sb-window and sb-sort) with ?count= stars from ?offset= (at most 500) in the
// order asked for (?key=, ?dir=), and says which order it used. With
// &cells=rich, the rows hold cell objects (demoStarCells). fit is each
// column's width for the whole catalog (demoStarFit).
func (s *Server) demoRows(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
offset, _ := strconv.Atoi(q.Get("offset"))
count, err := strconv.Atoi(q.Get("count"))
if err != nil {
count = 100
}
offset, count = max(offset, 0), min(max(count, 1), 500)
key, dir := q.Get("key"), q.Get("dir")
if !queries.DemoStarSortable(key) {
key, dir = "", ""
} else if dir != "desc" {
dir = "asc"
}
var stars []demo.Star
var total int
if err := s.q.View(r.Context(), func(rd *queries.Reader) (err error) {
stars, total, err = rd.DemoStars(r.Context(), key, dir == "desc", offset, count)
return
}); err != nil {
s.fail(w, r, err)
return
}
window := map[string]any{"rows": stars, "offset": offset, "total": total, "sort": map[string]string{"key": key, "dir": dir}, "fit": s.demoStarFit(r.Context(), total, q.Get("cells") == "rich")}
if q.Get("cells") == "rich" {
rows := make([]map[string]any, len(stars))
for i, st := range stars {
rows[i] = demoStarCells(st)
}
window["rows"] = rows
}
s.demoAnswer(w, r, "_rows", window, window)
}
// demoAnswer writes the list as JSON, or patches it into the requested signal.
func (s *Server) demoAnswer(w http.ResponseWriter, r *http.Request, defaultSignal string, list, patch any) {
w.Header().Set("Access-Control-Allow-Origin", "*") // public; used from the playground sandbox
if !demoWait(r) {
return
}
// Datastar's own requests accept JSON too: they always get the patch.
if r.Header.Get("Datastar-Request") == "" && strings.Contains(r.Header.Get("Accept"), "application/json") {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Cache-Control", "public, max-age=300")
json.NewEncoder(w).Encode(list)
return
}
into := r.URL.Query().Get("into")
if into == "" {
into = defaultSignal
}
if !signalNameRe.MatchString(into) {
http.Error(w, "into must be a signal name", http.StatusBadRequest)
return
}
js, err := json.Marshal(map[string]any{into: patch})
if err != nil {
s.fail(w, r, err)
return
}
// Through lith's sse, which compresses: the edge leaves text/event-stream to it.
if stream, err := sse.Open(w, r, sse.Options{}); err == nil {
stream.CloseWith(sse.PatchSignals(js, false))
}
}
The query asks SQLite for one window in one order. Every sortable column has an index, and the id breaks ties, so the windows of one order fit together. OFFSET walks the index: the last window of 100,000 rows takes about a millisecond.
// starOrder maps a sort key of the star catalog to its column: the class
// sorts by temperature.
var starOrder = map[string]string{
"name": "name", "class": "temp", "constellation": "constellation",
"distance": "distance", "magnitude": "magnitude",
}
// starOrderBy is the ORDER BY for sort (a key of starOrder, else the
// catalog's own order). Ties go in id order (the indexes hold it), so every
// window of one order fits the next.
func starOrderBy(sort string, desc bool) string {
col, dir := starOrder[sort], " ASC"
if col == "" {
col = "id"
}
if desc {
dir = " DESC"
}
return col + dir + ", id" + dir
}
// DemoStars returns up to count stars from offset, sorted by sort (a key of
// starOrder, else the catalog's own order), and how many stars there are.
func (r *Reader) DemoStars(ctx context.Context, sort string, desc bool, offset, count int) ([]demo.Star, int, error) {
var total int
if err := r.tx.QueryRowContext(ctx, `SELECT count(*) FROM demo_stars`).Scan(&total); err != nil {
return nil, 0, err
}
rows, err := r.tx.QueryContext(ctx, `SELECT id, name, class, temp, constellation, distance, magnitude, planets FROM demo_stars
ORDER BY `+starOrderBy(sort, desc)+` LIMIT ? OFFSET ?`, count, offset)
if err != nil {
return nil, 0, err
}
defer rows.Close()
out := []demo.Star{}
for rows.Next() {
var s demo.Star
if err := rows.Scan(&s.ID, &s.Name, &s.Class, &s.Temp, &s.Constellation, &s.Distance, &s.Magnitude, &s.Planets); err != nil {
return nil, 0, err
}
out = append(out, s)
}
return out, total, rows.Err()
}
Exports
A page puts its own export buttons in the toolbar slot, and they call the table's requestExport(format) (csv by default), which emits sb-export with {name, format, sort, columns, selected}: the order on screen, the keys of the shown columns in their order, and the user's selection. The table never builds a file and never asks for the rows: the server has them. The page turns the event into a download of /demo/data/rows/export, which checks every parameter, is rate limited (per session, three downloads in a row, then one every five seconds; the whole server streams at most two at a time), and streams the file. The whole catalog is 100,000 rows; it goes out compressed, and the browser never holds more than the window it shows. demoStarCells is the rich rows' shape from the first example:
// demoRowsExport answers sb-data-table's sb-export with a download of the star
// catalog: ?format=csv or json, in the order asked for (?key=, ?dir=), the
// ?columns= in their order (default: all), and with ?selected= only those
// stars (at most 1000 ids). The rows stream from one read transaction, so the
// whole catalog never sits in memory, and go out compressed.
func (s *Server) demoRowsExport(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
format := q.Get("format")
if format != "csv" && format != "json" {
http.Error(w, "format must be csv or json", http.StatusBadRequest)
return
}
key, dir := q.Get("key"), q.Get("dir")
if !queries.DemoStarSortable(key) {
key, dir = "", ""
} else if dir != "desc" {
dir = "asc"
}
columns := demoStarColumns
if c := q.Get("columns"); c != "" {
columns = strings.Split(c, ",")
for i, k := range columns {
if !slices.Contains(demoStarColumns, k) {
http.Error(w, "unknown column "+strconv.Quote(k), http.StatusBadRequest)
return
}
if slices.Contains(columns[:i], k) {
http.Error(w, "column "+strconv.Quote(k)+" twice", http.StatusBadRequest)
return
}
}
}
var ids []int
if sel := q.Get("selected"); sel != "" {
list := strings.Split(sel, ",")
if len(list) > 1000 {
http.Error(w, "at most 1000 selected ids", http.StatusBadRequest)
return
}
for _, v := range list {
id, err := strconv.Atoi(v)
if err != nil {
http.Error(w, "selected must be ids", http.StatusBadRequest)
return
}
ids = append(ids, id)
}
}
now := time.Now()
if !s.exportLimitIP.Allow(edge.ClientKey(r), 1, now) || !s.exportLimit.Allow(edge.SessionID(r.Context()), 1, now) {
w.WriteHeader(http.StatusTooManyRequests)
return
}
// A download holds a read connection until it ends: slow ones must not
// take them all from the pages, and one that stalls for a minute ends.
select {
case s.exports <- struct{}{}:
defer func() { <-s.exports }()
default:
w.Header().Set("Retry-After", "5")
w.WriteHeader(http.StatusServiceUnavailable)
return
}
rc := http.NewResponseController(w)
rc.SetWriteDeadline(time.Now().Add(time.Minute))
h := w.Header()
h.Set("Access-Control-Allow-Origin", "*") // public; used from the playground sandbox
h.Set("Cache-Control", "public, max-age=300")
h.Set("Content-Disposition", `attachment; filename="stars.`+format+`"`)
// Each star is written as it comes from the cursor.
var write func(demo.Star) error
var end func() error
if format == "csv" {
h.Set("Content-Type", "text/csv; charset=utf-8")
cw := csv.NewWriter(w)
cw.Write(columns)
row := make([]string, len(columns))
write = func(st demo.Star) error {
for i, k := range columns {
switch v := demoStarField(st, k).(type) {
case float64:
row[i] = strconv.FormatFloat(v, 'f', -1, 64) // 1234567, never 1.234567e+06
default:
row[i] = fmt.Sprint(v)
}
}
return cw.Write(row)
}
end = func() error { cw.Flush(); return cw.Error() }
} else {
h.Set("Content-Type", "application/json")
bw := bufio.NewWriter(w)
bw.WriteString("[")
sep := ""
write = func(st demo.Star) error {
obj := []byte(sep + "{")
for i, k := range columns {
if i > 0 {
obj = append(obj, ',')
}
v, err := json.Marshal(demoStarField(st, k))
if err != nil {
return err
}
obj = append(append(strconv.AppendQuote(obj, k), ':'), v...)
}
sep = ",\n"
_, err := bw.Write(append(obj, '}'))
return err
}
end = func() error { bw.WriteString("]\n"); return bw.Flush() }
}
n := 0
err := s.q.View(r.Context(), func(rd *queries.Reader) error {
return rd.EachDemoStar(r.Context(), key, dir == "desc", ids, func(st demo.Star) error {
if n++; n%1000 == 0 {
rc.SetWriteDeadline(time.Now().Add(time.Minute))
}
return write(st)
})
})
if err == nil {
err = end()
}
if err != nil {
// A file cut short must not look complete: the download fails instead.
if r.Context().Err() == nil {
s.log.Error("export failed", "err", err)
}
panic(http.ErrAbortHandler)
}
}
// demoStarCells is a star as sb-data-table's cell objects: the name links to
// the star (an in-page link the demo cancels, to run an action instead), the
// distance carries its unit, and the magnitude of a star the naked eye can see
// (6 or brighter) shows as a badge.
func demoStarCells(st demo.Star) map[string]any {
var magnitude any = st.Magnitude
if st.Magnitude <= 6 {
magnitude = map[string]any{"value": st.Magnitude, "tone": "info"}
}
return map[string]any{
"id": st.ID,
"name": map[string]any{"value": st.Name, "href": "#star-" + strconv.Itoa(st.ID)},
"class": st.Class,
"temp": st.Temp,
"constellation": st.Constellation,
"distance": map[string]any{"value": st.Distance, "suffix": "ly"},
"magnitude": magnitude,
"planets": st.Planets,
}
}
It reads the stars from a cursor in the same order as the windows, so the file has the order the table shows:
// EachDemoStar calls fn with every star in the order DemoStars gives them, or
// only with the stars whose id is in ids, and stops at fn's first error. The
// rows stream from the cursor: a whole export never sits in memory.
func (r *Reader) EachDemoStar(ctx context.Context, sort string, desc bool, ids []int, fn func(demo.Star) error) error {
where, args := "", make([]any, len(ids))
if len(ids) > 0 {
ctx = sqlite.Uncached(ctx) // a text per length of the list
where = ` WHERE id IN (?` + strings.Repeat(", ?", len(ids)-1) + `)`
for i, id := range ids {
args[i] = id
}
}
rows, err := r.tx.QueryContext(ctx, `SELECT id, name, class, temp, constellation, distance, magnitude, planets FROM demo_stars`+where+`
ORDER BY `+starOrderBy(sort, desc), args...)
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
var s demo.Star
if err := rows.Scan(&s.ID, &s.Name, &s.Class, &s.Temp, &s.Constellation, &s.Distance, &s.Magnitude, &s.Planets); err != nil {
return err
}
if err := fn(s); err != nil {
return err
}
}
return rows.Err()
}
A real server should also neutralise text cells that start with =, +, - or @ (for example with a leading '), or a spreadsheet that opens the CSV may run them as formulas. The star catalog has no text like that.
With commands
Give it a name and a selection, and it emits sb-change with { name, value } (an array of row keys) when the selection changes: ready to post as a command. With confirm, it sets :state(pending) until the server's re-rendered selected matches, and revert() goes back to the server's selection when a command never reaches the server (an error status, or retries-failed). See Commands and components.
A new selected from the server always wins, and selected="[]" clears it. Markup re-sent with the same selected leaves the user's selection alone. The order (sort) is not part of the value: it only ever comes from the server. Neither are hidden-columns and widths: they are view state with their own events (sb-columns, sb-column-widths), never pending, and revert() leaves them as they are.
Refusals without page code: give it rev, a number the server bumps with every command it answers for this field, applied or refused (a counter in the tab's state will do; templ: Rev: sb.Int(n)). A new rev makes the server's selected win even when it is unchanged, so a refused selection goes back and :state(pending) ends, without a revert() from the page; the same rev again changes nothing. When both change in one morph, the new selection applies once. hidden-columns and widths are view state: rev leaves them. The page's op ids (see Commands and components) do the same for every component; rev needs nothing on the page. rev only helps where the server renders the outcome into this element's own frame. A view rendered once for every tab, and an outcome no command records (a rate limit, a failed request, being offline), need revert() instead: see When rev is enough.
Pending from the page: pending is the page's word that a command is on its way. While the attribute is there, the component has :state(pending) and aria-busy (on its ElementInternals, so morphs keep them), whatever confirm says: data-attr:pending="$_saving", with a signal the page sets when it sends and the server's answer clears. The two add up: removing pending leaves an unconfirmed edit pending, and revert() leaves the page's pending. In a region the server morphs, a signal-driven pending needs data-preserve-attr="pending".
Columns and rows
columns:[{key, label?, width?, align?, sortable?, resizable?, min?, fit?}].widthis a CSS grid track ("8rem","minmax(4rem, 2fr)", a number for px; defaultminmax(6rem, 1fr)). Widths whose minimum is a length keep the columns steady while rows come and go; a table wider than its box scrolls sideways. The header and every row are grids of their own, sochandemresolve in each row's font: give header text its font, size or weight through::part(column), never::part(header), or the header's columns drift away from the rows'.alignisstart,centerorend.rows: objects keyed by column. Numbers show in the reader's format (4,242.5), everything else as text. The field named byrow-key(defaultid) identifies a row.- A value can also be a cell object,
{value, text?, suffix?, href?, tone?}:valueis the raw value: the sort key, whatsb-cell-activatereports, and the text when there is notext(formatted like a plain value).textis shown instead of the formattedvalue, andsuffixafter it in a muted colour (the table adds the space).hrefmakes the text a link, but only when it resolves (against the page's URL) tohttp:,https:ormailto:. Anything else, such asjavascript:ordata:, shows plain text.toneshows the text as a badge:info,success,warning,dangerorneutral. Any other tone is ignored.- Nothing in a cell is ever read as HTML:
<b>stays the text<b>. Other fields are ignored, and a row's key may be a cell object too (itsvalueis the key).
- A click or middle click on a link, or Enter on its cell, emits
sb-cell-activatewith{key, column, value, href}. It is cancelable: a listener that callspreventDefault()stops the navigation (a middle click then opens no tab) and can run an action instead, such asdata-on:sb-cell-activate="evt.detail.column === 'ip' && (evt.preventDefault(), @post('/ip-info?ip=' + encodeURIComponent(evt.detail.value)))". A click on a link doesn't select the row. offsetis the index of the first row inrows, andtotalthe number of rows there are. Withouttotal, the table has what it was given.- Sorting: a table that holds every row (
offset0, and nototalor one no larger than the rows given) sorts them itself when a sortable header is clicked. Numbers sort by value, text in the reader's order (with numbers inside it by value, so "Io 2" comes before "Io 10"), and missing values last. A cell object sorts by itsvalue, else itstext. It still emitssb-sort, a newsortfrom the server wins, and rows the server sends in are sorted the same way, so their order doesn't jump. A table that holds only a window asks, and the server sends the rows in the new order. row-heightis fixed (default36px), andbuffer(default4000px of rows) is how much the table keeps ready above and below the view.- A server that sends fewer rows than asked for (a cap) still fills the view: the table then asks for windows that fit the cap.
- Resizing (
resizable, see above): per column,resizable: false,min(px, default40) andfit(px). A fit is never narrower than the header nor wider than 2000 px. - A cell too narrow for its text ends in an ellipsis. Pointed at or focused, it shows the whole text over its neighbours, without changing the row's height or the table's scroll size; a cell in the last column grows toward the start. Only clipped cells do this.
- Browsers cap how tall an element can be, Firefox at about 17.9 million px (Chrome and Safari at about 33.5 million). Keep rows ×
row-heightunder that: 100,000 rows of 36 px are 3.6 million px.
Forms
sb-data-table is not a form-associated element: a <form> doesn't submit its selection, and FormData and Datastar's contentType: 'form' don't see it. Send the selection as a command instead: sb-change carries { name, value } (see With commands).
Text and language
Every text it shows or reads out is a prop with an English default, so a page in another language sets them all. {name} in a text stands for a value it fills in.
label: "Table", the table's name.columns-label: "Columns",reset-widths-label: "Reset column widths",resize-hint: "Drag to resize, double-click to fit".- Numbers in cells are formatted, and the rows sorted, with
Intlin the element's language: the nearestlangattribute (inside another component, the page's), else the browser's.
Styling
Style it from your page's CSS, without changing the component or importing anything into it. Custom properties, inherited properties and ::part() all reach into its shadow root.
- Size: it fills the width it is given and is at most
24remtall; setblock-sizeormax-block-sizeon the element to change that. Rows arerow-heighttall. Setfont-sizeon the element (default0.875rem) to scale the text. - Fonts: the header and the cells use your page's font.
- Colours: the table is
--sb-surface-cardwith a--sb-borderframe, rows are separated by--sb-border-subtlelines, and placeholders are sb-virtual-scroll's--sb-surface-hoverbars. The header is--sb-surface-raisedwith--sb-text-2labels; cells are--sb-text-1. A row turns--sb-surface-hoveron hover; a selected row is--sb-brand-subtlewith a--sb-brandedge. The focus ring and the sort arrow are--sb-brand-light. Corners are--sb-radius, or pixel notches while--sb-notchis 1, which also makes the sort arrow a stepped pixel one (a plain triangle at 0). - Shadow:
--sb-shadow-overlaysets the column picker's drop shadow: one shadow without spread, such as0 8px 16px rgb(0 0 0 / 0.3), ornone. - Toolbar: it shows above the table with
column-picker, or while a control you put in its slot shows (one withhidden, or hidden bydata-show, doesn't count). The Columns button and its menu are--sb-surface-raisedwith a--sb-borderframe and--sb-text-2text; checkboxes take--sb-brand. A<button>you put in the slot looks like the Columns button until your page styles it. - Resize grips: a
--sb-borderline, dashed while--sb-notchis 1, and a wider--sb-brand-lightone while pointed at, dragged or focused (CanvasTextandHighlightin forced colours). - Peeks: on
--sb-surface-hover, with an edge shadow from--sb-text-1(an outline in forced colours). - Rich cells: links are
--sb-brand-lightand underlined, suffixes--sb-text-muted. Badges take their tone from--sb-info,--sb-ok,--sb-warnand--sb-danger(neutralfrom--sb-text-muted), with a tinted background and border. - Parts:
grid(the sb-virtual-scroll that scrolls),header(the header row; its font sizes thechandemof column widths, so set fonts oncolumn),column(a header cell),rowandcell. Selected rows are alsoselected, so::part(row selected)styles only those. In rows with cell objects, a cell holds atext(alsolinkfor a link,badgefor a badge, so::part(text badge)styles only badges) and asuffix. Above the table:toolbar,columns-button,columns-menu(the popover),column-option(a label with its checkbox) andreset-widths(the menu's reset item). In a header,column-gripis the resize grip. Your page's::part()rules win over the component's own, without!important.
<style>
.my-table { --sb-brand: var(--sb-accent); }
.my-table::part(column) { text-transform: uppercase; font-size: 0.75rem; }
.my-table::part(row selected) { font-weight: 700; }
</style>
<sb-data-table class="my-table" label="Planets" selection="single" selected='["earth"]' row-height="40"
columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end"}]'
rows='[{"id":"venus","name":"Venus","moons":0},{"id":"earth","name":"Earth","moons":1},{"id":"mars","name":"Mars","moons":2}]'></sb-data-table>
Accessibility
It follows the WAI-ARIA grid pattern:
- Structure: a
gridwitharia-rowcountfor every row there is (plus the header), andaria-rowindexon each rendered row, so a screen reader knows where it is in the whole table, not in the few rows the page holds. Sorted headers havearia-sort; with aselection, rows havearia-selected. The grid isaria-busywhileloadingis set. - Focus: one cell at a time is in the tab order: the first header, then the cell focused last, or the header again once that cell's row is gone. Sortable headers are buttons.
- Keys: the arrows move between cells, Home and End to the first and last cell of the row, Ctrl+Home to the first header, Ctrl+End to the last cell of the last row, Page Up and Page Down by a view. Moving past the rendered rows scrolls there, and the focus lands when the rows arrive. Space selects or unselects the row, Enter emits
sb-row-activate(so does a double click, which selects only once). On a sortable header, Enter or Space sorts. - Links in cells: a link is not a tab stop of its own; the cell is, and Enter on it follows the link (after
sb-cell-activate). Space still selects the row. - Resizing: the grips are no tab stops. Alt+ArrowRight or Alt+ArrowLeft on a header moves to its separator (named by the column, with
aria-valuenow,-valuemin,-valuemaxand-valuetextin px), where the arrows change the width by 8 px (32 with Shift; mirrored right to left), Home goes to the minimum and End fits. Enter, Tab and Escape go back to the header; Escape also restores the width. Headers are named by their titles, so a separator's value never joins a header's name. - Column menu: the Columns button has
aria-haspopup="dialog"andaria-expanded, and opens a dialog named bycolumns-labelwith a native checkbox per column. The focus goes to the first checkbox; Tab and Shift+Tab cycle through them, Space toggles one (the focus stays on it), and Escape closes only the menu, also inside a drawer, and returns the focus to the button. - Badges: a tone is colour only, so the badge's text has to carry the meaning ("Failed", not a red dot). In forced colours, links use the system's link colour and badges keep a border.
Installation
Add Datastar with Rocket and the Starbase autoloader once per page, then use the tag: the autoloader imports each component the first time its tag appears, including tags a Datastar morph adds later. The Datastar here is v1.0.5 with Starbase's patches. The components also run on the official v1.0.4 and v1.0.5.
<script type="importmap">
{ "imports": { "datastar": "https://starbase.zweiundeins.gmbh/c/datastar@5f98646d7d3d/datastar-rocket.js" } }
</script>
<script type="module" src="https://starbase.zweiundeins.gmbh/c/autoloader.js"></script>
<sb-data-table label="Planets" columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end"}]' rows='[{"id":"earth","name":"Earth","moons":1},{"id":"mars","name":"Mars","moons":2}]'></sb-data-table>No flash of undefined elements: put class="sb-cloak" on <html> and add .sb-cloak :not(:defined) { visibility: hidden } to your CSS. The autoloader removes the class once the page's components are defined.
Load just this component, pinned to this version: all its modules in one minified file with its integrity hash, so the browser refuses it if a single byte changes. It renders <sb-virtual-scroll>, so that is pinned here too.
<script type="importmap">
{
"imports": { "datastar": "https://starbase.zweiundeins.gmbh/c/datastar@5f98646d7d3d/datastar-rocket.js" },
"integrity": {
"https://starbase.zweiundeins.gmbh/c/datastar@5f98646d7d3d/datastar-rocket.js": "sha384-AfXVdZ/qxhMEHK4Nz/pJT6jl9xm3HGMBLBtC9yRuU5A7AQtXHYC0x6ap034vDqBV"
}
}
</script>
<script type="module" src="https://starbase.zweiundeins.gmbh/c/data-table@3b5fcae2f9d8/data-table.bundle.min.js" integrity="sha384-Ffi0uTeo84G0SdZrEIBct/e97znWM+dbgGfCLRQsm/FW29DIrABZP2Gt4xtVQaoV"></script>
<script type="module" src="https://starbase.zweiundeins.gmbh/c/virtual-scroll@1e89e0453b4e/virtual-scroll.bundle.min.js" integrity="sha384-t+XsA2ZFVGabfDck378RXANlxMScZHvkJzyJUCuLnEb4ibJ6+ynjJsPMdiRCF1CE"></script>
<sb-data-table label="Planets" columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end"}]' rows='[{"id":"earth","name":"Earth","moons":1},{"id":"mars","name":"Mars","moons":2}]'></sb-data-table>Or the minified module files (2 files, which the browser requests as it finds their imports), each pinned in the import map:
<script type="importmap">
{
"imports": { "datastar": "https://starbase.zweiundeins.gmbh/c/datastar@5f98646d7d3d/datastar-rocket.js" },
"integrity": {
"https://starbase.zweiundeins.gmbh/c/datastar@5f98646d7d3d/datastar-rocket.js": "sha384-AfXVdZ/qxhMEHK4Nz/pJT6jl9xm3HGMBLBtC9yRuU5A7AQtXHYC0x6ap034vDqBV",
"https://starbase.zweiundeins.gmbh/c/data-table@3b5fcae2f9d8/data-table.min.js": "sha384-+E4m93JkLFPWBaLgsLt5dwSZYoDUOws7IC8XlIZeX5BW5RJ+dIUc8ct7cE9kzw3n",
"https://starbase.zweiundeins.gmbh/c/virtual-scroll@1e89e0453b4e/virtual-scroll.min.js": "sha384-sNWlpttwgOdpTFXmcv12dbwqp6ZFdiKmybY+vJP4ZnU1J06GYlXKC1KomT1IWUoI"
}
}
</script>
<script type="module" src="https://starbase.zweiundeins.gmbh/c/data-table@3b5fcae2f9d8/data-table.min.js" integrity="sha384-+E4m93JkLFPWBaLgsLt5dwSZYoDUOws7IC8XlIZeX5BW5RJ+dIUc8ct7cE9kzw3n"></script>
<script type="module" src="https://starbase.zweiundeins.gmbh/c/virtual-scroll@1e89e0453b4e/virtual-scroll.min.js" integrity="sha384-sNWlpttwgOdpTFXmcv12dbwqp6ZFdiKmybY+vJP4ZnU1J06GYlXKC1KomT1IWUoI"></script>
<sb-data-table label="Planets" columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end"}]' rows='[{"id":"earth","name":"Earth","moons":1},{"id":"mars","name":"Mars","moons":2}]'></sb-data-table>In production, pin today's whole catalog: its autoloader and an import map with integrity hashes, so the browser refuses any file that changed. This map covers Datastar and this component; importmap.json has the hashes of every component, to merge into yours.
<script type="importmap">
{
"imports": { "datastar": "https://starbase.zweiundeins.gmbh/c/datastar@5f98646d7d3d/datastar-rocket.js" },
"integrity": {
"https://starbase.zweiundeins.gmbh/c/datastar@5f98646d7d3d/datastar-rocket.js": "sha384-AfXVdZ/qxhMEHK4Nz/pJT6jl9xm3HGMBLBtC9yRuU5A7AQtXHYC0x6ap034vDqBV",
"https://starbase.zweiundeins.gmbh/c/data-table@3b5fcae2f9d8/data-table.bundle.min.js": "sha384-Ffi0uTeo84G0SdZrEIBct/e97znWM+dbgGfCLRQsm/FW29DIrABZP2Gt4xtVQaoV",
"https://starbase.zweiundeins.gmbh/c/virtual-scroll@1e89e0453b4e/virtual-scroll.bundle.min.js": "sha384-t+XsA2ZFVGabfDck378RXANlxMScZHvkJzyJUCuLnEb4ibJ6+ynjJsPMdiRCF1CE"
}
}
</script>
<script type="module" src="https://starbase.zweiundeins.gmbh/c/@81f24b268adb/autoloader.js" integrity="sha384-bWIhsIq9SpNUiIZyG/lv190MgHA05m8BVYA3LyIoE/pgOF3NUt0437e++4Ht1NcS"></script>
<sb-data-table label="Planets" columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end"}]' rows='[{"id":"earth","name":"Earth","moons":1},{"id":"mars","name":"Mars","moons":2}]'></sb-data-table>Components import only datastar and their own files, so copying is enough: save each component's one file (and a file it loads on first use, keeping its folder), and point the import map at your own copy of datastar-rocket.js (the /js/ paths stand for yours).
<sb-data-table>data-table.bundle.min.jsone file 9.1 kB brotli
<sb-virtual-scroll>virtual-scroll.bundle.min.jsone file 3.3 kB brotli
<script type="importmap">
{ "imports": { "datastar": "/js/datastar-rocket.js" } }
</script>
<script type="module" src="/js/data-table/data-table.bundle.min.js"></script>
<script type="module" src="/js/virtual-scroll/virtual-scroll.bundle.min.js"></script>
<sb-data-table label="Planets" columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end"}]' rows='[{"id":"earth","name":"Earth","moons":1},{"id":"mars","name":"Mars","moons":2}]'></sb-data-table>Or copy the module files, keeping each component's folder, and load each component's module:
<sb-data-table><sb-virtual-scroll>
<script type="importmap">
{ "imports": { "datastar": "/js/datastar-rocket.js" } }
</script>
<script type="module" src="/js/data-table/data-table.min.js"></script>
<script type="module" src="/js/virtual-scroll/virtual-scroll.min.js"></script>
<sb-data-table label="Planets" columns='[{"key":"name","label":"Planet"},{"key":"moons","label":"Moons","align":"end"}]' rows='[{"id":"earth","name":"Earth","moons":1},{"id":"mars","name":"Mars","moons":2}]'></sb-data-table>In Go, render it with its typed templ wrapper: one field per prop, generated from the component's manifest (the module's README has the type rules). Add the module:
go get github.com/zweiundeins/starbase/templ@latestThen load it, pinned with integrity hashes to the versions the module was generated with, and use it:
// In <head>: the components you list, pinned,
@sb.Imports(sb.ImportsProps{Components: []sb.Tag{sb.TagDataTable}})
// or the autoloader, which also loads tags a morph adds later: @sb.Imports(sb.ImportsProps{})
// or, around the content of <body>, the components it renders: @sb.Tracked(sb.ImportsProps{}) { … }
@sb.DataTable(sb.DataTableProps{
Label: "Planets",
Columns: []sb.Column{
{Key: "name", Label: "Planet"},
{Key: "moons", Label: "Moons", Align: sb.ColumnAlignEnd},
},
Rows: []map[string]any{
{"id": "earth", "moons": 1, "name": "Earth"},
{"id": "mars", "moons": 2, "name": "Mars"},
},
})Size
A page loads this component as one file, its bundle, and the bundle of each component it renders, each compressed on its own the way it is served (gzip -9, brotli -11): brotli is what it downloads. Datastar and Rocket are shared by every component and not counted.
| File | Original | gzip | brotli |
|---|---|---|---|
data-table.bundle.min.js | 26.9 kB | 9.9 kB | 9.1 kB |
virtual-scroll.bundle.min.js renders it | 7.9 kB | 3.6 kB | 3.3 kB |
| Total | 34.9 kB | 13.5 kB | 12.3 kB |
As module files: 2 requests, 12.2 kB minified with brotli
For a page that loads the module files as they are, requesting each one as it finds its import, or bundles them itself. Each file compressed on its own; the minified one is what the page downloads, and the readable source is always there too.
| File | Original | gzip | brotli | minified |
|---|---|---|---|---|
data-table.js | 57.3 kB | 17.2 kB | 15.3 kB | 9.0 kB |
<sb-virtual-scroll> renders it | 21.9 kB | 7.2 kB | 6.3 kB | 3.2 kB |
| Total | 79.2 kB | 24.4 kB | 21.6 kB | 12.2 kB |
API reference
Props
| Attribute | Type | Default | Description |
|---|---|---|---|
columns | json | [] | The columns: [{key, label?, width?, align?, sortable?, resizable?, min?, fit?}]. With resizable: resizable: false keeps a column's width, min is its narrowest (px, default 40), fit its width for the whole result (px). width is a CSS grid track (a number is px; default minmax(6rem, 1fr)); ch and em resolve in each row's own font, so style header text through ::part(column), never ::part(header); align is start, center or end. A row's value for a key is a scalar or a cell object {value, text?, suffix?, href?, tone?}. |
rows | json | [] | The rows at hand, objects keyed by column: all of them, or the window the server sent, starting at row offset. A value is a scalar, or a cell object {value, text, suffix, href, tone}: text replaces the formatted value, suffix follows it muted, href (http, https or mailto) makes it a link, tone (info, success, warning, danger, neutral) a badge. value is the sort key. Nothing is rendered as HTML. |
offset | number | 0 | Index of the first row in rows. |
total | number | 0 | How many rows there are (at least offset plus the rows given). |
row-key | string | "id" | The field that identifies a row, for the selection and sb-row-activate. |
row-height | number | 36 | The height of every row, in px: fixed, so the scroll position tells which rows are in view. |
buffer | number | 4000 | How much to keep ready above and below the view, in px of rows. |
sort | json | {} | The order the rows are in: {key, dir: "asc" | "desc"}. The server sends it with the rows. When the table holds every row (offset 0, no more than total), a header click sorts them here too; otherwise it asks for the order (sb-sort). A new sort from the server wins. |
loading | boolean | false | Rows are on their way (bind it to data-indicator): the table is aria-busy. |
selection | "none" | "single" | "multiple" | "none" | How many rows can be selected. |
selected | json | [] | The selection: a JSON array of row keys. A new list from the server replaces it; the live value is the selected property. |
label | string | "Table" | Accessible name. |
confirm | boolean | false | Server-confirmed selection: :state(pending) while the local selection differs from the server's selected attribute (see revert()). |
rev | number | 0 | Revision of the server's value, for commands: the server bumps it with every command it answers for this field, applied or refused. A new rev makes the selected attribute win even when it is unchanged, so a refused edit reverts. |
pending | boolean | false | The page's word that a command is on its way (e.g. data-attr:pending="$_saving"): :state(pending) and aria-busy while present. It adds to confirm's pending, never clears it. |
name | string | "" | Name reported in sb-change, sb-columns and sb-export (e.g. the field of a command). |
hidden-columns | json | [] | View state: the keys of the columns not shown, as a JSON array. A changed list from the server wins; the same list again keeps the user's choice. The live list is the hiddenColumns property. At least one column always shows. |
column-picker | boolean | false | Show a Columns button in the toolbar, with a menu that shows and hides columns (sb-columns). |
columns-label | string | "Columns" | The Columns button's text, and the accessible name of its menu. |
resizable | boolean | false | The user can resize columns: a grip at each header's end (drag, double-click to fit), or Alt+Arrow to its separator. |
widths | json | {} | View state: widths in px by column key, {"name": 180}, over the columns' width. A new object from the server wins, the same one keeps the user's; the live map is the widths property. |
resize-hint | string | "Drag to resize, double-click to fit" | The resize grip's tooltip. |
reset-widths-label | string | "Reset column widths" | The column picker's reset item. |
Slots
| Name | Description |
|---|---|
toolbar | Your own controls (e.g. export buttons), in a toolbar above the table, before the Columns button. |
Events
| Name | Description |
|---|---|
sb-window | The view needs rows the table doesn't have (also on connect and on resize): detail { offset, count }, plus key and dir of the order to send them in. Answer with rows from that offset, offset and total. |
sb-sort | A sortable header was clicked. detail: { key, dir }, plus the window to answer with (offset 0, count). Answer with those rows in that order, and the new sort; a table that holds every row has sorted them already. |
sb-row-activate | Enter or a double click on a row (not on a link in it). detail: { key }. |
sb-cell-activate | A click or middle click on a link in a cell, or Enter on its cell. detail: { key, column, value, href }. Cancelable: preventDefault() stops the navigation, for an in-page action instead. |
change | The selection changed. |
sb-change | The selection changed. detail: { name, value } (an array of row keys): ready for a command. |
sb-export | requestExport(format) was called. detail: { name, format, sort: { key, dir }, columns, selected }: the order on screen, the keys of the shown columns in order, and the local selection. The page asks the server for the file; the table never builds one. |
sb-columns | The user showed or hid a column in the column picker. detail: { name, hidden } (the keys of every hidden column). View state: not emitted for a change the server made or a property write. |
sb-column-widths | The user resized a column (at the end of a drag, never during it). detail: { name, widths }, the whole map. Not emitted for the server's changes or a property write. |