Select all rows in a perspectives table

Unfortunately, Table.props.selection.data is read-only, and writing data to that property will not modify the state or appearance of the Table. The primary reason for this is that there is no guarantee of uniqueness in Table data.

Imagine you had a Table with a single column "x" (just to keep the example simple), and it only had three rows:

  x
-----
  1
  2
  1

Suppose now that you wrote the row data for the 2th (3rd) row with the expectation that the 2th row would display as selected. Well... {"x": 1} actually defines the underlying data of two rows, so which should be selected?

There's no good work around, because there is no current way for the Table to dynamically or systematically have selection applied to it.

A bad workaround is to add a new column to the Table (and your data) as the 0th column, render it as a boolean field (checkbox or toggle), and use some external component (perhaps a Button) to set the underlying value of the data to have all rows selected. You would also then need to supply your OWN style to each row to designate the row as selected.

2 Likes