Skip to content

Expose Table's current sort order #115

Open
@mootari

Description

@mootari

A Table input's current sort order is only tracked internally. This poses a problem if a notebook author wants to persist the current sort state, e.g. via a permalink.

Suggested solution

When the sort column or order is changed, dispatch a custom sort event:

new CustomEvent('sort', {bubbles: true, detail: {sort: currentColumnName, reverse: currentReverse}})

Workaround

The instantiating cell can listen to click events and parse order and column name from event.target.textContent. This technique is error prone and expected to break once additional features (like custom table names) have been added.

The workaround is currently implemented here: https://observablehq.com/@mootari/sortable-notebook-list#selection

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions