Unable to dynamically select a table row using selectRow

I'm using the "Table(new)" component to render a list of items, and would like to select all of the items in the list by default whenever a new query for data is complete.
Unfortunately I'm having trouble getting this to work by using the selectRow API as suggested in other threads such as this one and this one.

I've tried this both for tables in single-select and multi-select mode, and I can't get selectRow to do anything.


However, both the above cases seem to work fine if I use the Table(legacy) component instead. Is there a work-around that allows us to use the new table like this, or should we switch to legacy?

Definitely sounds like a feature that hasn't been implemented yet in the new table.


However if you look at .selectRow on new table it will return first matching value.

Additionally it seems like .selectRow in the new table only accepts a value and not array thus making this impossible perhaps?
image

Tagging @Alexi for visibility!

Thanks @jcd and @stefancvrkotic for writing in! selectRow doesn't currently support selecting multiple rows, but I've noted it as a feature request.

For the single select case, the selectRow API, takes in an object with mode which can be 'key' or 'index'. Use key for targeting a row by its primary key, otherwise use index to target an index by display, or data.

Some examples:

// Selects row with primary key 4
table1.selectRow({ mode: 'key', key: 4 })

// Selects the row that represents table1.data[4]
table1.selectRow({mode: 'index', indexType: 'data', index: 4})

// Selects 5th row visible on the table
table1.selectRow({mode: 'index', indexType: 'display', index: 4})

Hope this helps! We will make a note of the feedback to add more documentation to help guide the usage of the selectRow API.

1 Like

Thank you @AnnaW for the response!
Good to see that this is supported for single selections.
Support for selecting multiple rows is required for my use case but we can probably find a workaround for the near-term. :slight_smile: