Attr Tables

The Attr Tables extensions adds various features to attribute tables.

Usage

The script supports the following configuration attributes, to be added in the [[roam/js/attr-tables]] page:

  • Max Sorts - (Optional) The maximum number of sorts that any table should support. When the max gets hit, the new sort column replaces the sort column of lowest priority.

Whenever you create an Attribute Table, there will be a new sort icon next to each of the column headers. Clicking the sort icon will toggle between three states: Neutral, Ascending, and Descending.

The table will then be sorted based on the columns you clicked on. A marker next to each column will appear to show the sort priority.

Because attribute tables are view only, navigating away from the page will wipe out any previous sort you had applied. To solve this, you could add a Default Sort attribute as a child. The value should be a comma delimited list of each column with the type of sort you want sorted. For example, if I wanted a table sorted first by "foo" column ascending, followed by "bar" column descending, I would use the following default sort value:

Default Sort:: foo=Asc, bar=Des

The Max Sorts DB level configuration could also be applied at a table level, by adding the attribute as a child of the table.

Installation

var old = document.getElementById("attr-tables");
if (old) {
  old.remove();
}

var s = document.createElement("script");
s.src = "https://roamjs.com/attr-tables.js";
s.id = "attr-tables";
s.async = false;
s.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(s);

Demo