Programmatically Expand/Collapse (Expandable) Rows in Table

I would love the ability to only allow a single row in a table to be expanded when I have expandable rows enabled for that table. Ideally, this would be a setup selection, but I would also be OK with some sort of event handler where if the selected row changes, the previously selected row collapses and they newly selected row expands.

Sometime it is nice to have multiple rows opened, sometimes it gets noisy and would be better to have only 1.

Thanks!

p.s. see also How to deselect a row in a single-select table? and Dynamically unselect all table rows for other examples of things that should not require custom code in the (new) Table component.

4 Likes

+1

+10

+1!

Looking to migrate an app from a clunky listview to the new table but it really needs to be able to expand rows programmatically.

+1

+10
And the option to table.closeAllExpandedRows()
:slight_smile:

4 Likes

+1

And also for table.closeAllExpandedRows()

1 Like

+1,000,000 :man_facepalming:

1 Like

+10 (myself and all my techs in the field that view data in this format).

1 Like

This is a must have guys, come on

+1

+1

+1

Hi there! Excited to share that Cloud now has expandRows and collapseRows methods for the table :slightly_smiling_face: (it should ship to on prem in the next couple of weeks)

4 Likes

:metal: :partying_face:

Thank you!

Yes!! Thank you to you and the Retool development team!!

Starting to implement now; will start new topics for anything that comes up as I do.

2 Likes

Looks like the way to expand all rows is this (assuming checklist_item_id is my table's key):

tblOutstandingChecklistItems.expandRows({
    mode:"key", 
    key: tblOutstandingChecklistItems.data.map(obj => obj.checklist_item_id)
})

Or if you are not using a key (and spread operator syntactic sugar is giving me diabetes :rofl:):

await tblOutstandingChecklistItems.expandRows({
    mode:"index", 
    index: [...Array(tblOutstandingChecklistItems.data.length).keys()]
})

Am I correct or is there a better way?

1 Like

Yes, I agree - not sure there's a better way currently

Can't seem to make it work. Am I doing it correctly? Thanks a lot!

Hi @freekz It looks like you're using grouped rows, and the expandRows method is for the expandable rows feature. If you have expandable rows that are also grouped, it looks like the group needs to be open in order to expand the underlying rows.