Action to change row order

Hi Codans

Wondering whether others would find it useful to have a new action (via a button or automation) to:

  • Move a row to sit above or below another row in the same table, e.g. moveRow(a, b, c) where a is the reference of the row you want to move, b is the reference of the row you want a to be adjacent to, and c is a boolean value that determines whether a is above or below b.

  • Re-order all the rows in a table according to a sort function, i.e. not just applying a sort, but re-ordering their “base” positions in the table as if you had dragged them up or down, e.g. tableOrder(a, b, c) where a is the name of the table you want to re-order, b is the column you want to sort by, and c is boolean value switching between ascending and descending order.

I often find myself wanting to be able to change the order of rows in a table via a button or automation. Using ‘Sort’ is often not an option, because once a table or view has a Sort order applied, users can no longer grab and re-order rows for themselves.

This is a really common issue when using Coda for task management - the order of task items in a list is often used as an indication of relative priority, and users generally need to be able to re-order tasks for themselves, but it’s also not uncommon for there to be workflow events that should bump an item to the top or bottom of the list, or move one item above or below another. The same need has popped up in a number of my other Coda use cases too, though it’s probably TMI if I go into detail here.

Anyway, will be interested to see whether others have a similar need, or whether there are alternative solutions I have missed.

1 Like

Happen to be looking for just this sort of thing too. Need some way to more easily order things while not being locked into a sort (so users can manually move things around).

voting for this also.

right now i force the reordering of my base table using a button
it first copies all the records from the base table to a second identical table as a backup
then it takes those records, sorts them by the ‘Order’ column, and inserts them back into the original base table (having wiped it first)

the button formula looks like this
image

its VERY crude (so maybe one of you whizz-kids can suggest a less drastic way ??? )
i have to name each of the non-formula columns in BOTH addrows() lines
and if the table gets new (non-formula) columns, i have to modify the button formula by hand

but at least the order of the records is reordered as if i moved them manually
and i get a snapshot backup of the data as a ‘free’ by-product of the process

respect
max

Crude, maybe, but clever! The one obvious downside is losing comment threads and row history. Useful to know this is an issue for others too.

2 Likes

Just giving this a cheeky bump to see if it generates any more interest (hint: votes!) from other users who encounter similar issues. Currently working on a doc where this feature would make a big difference.

I found a cleaner temporary solution, based on @Xyzor_Max’s;

Table.Sort().ForEach(RunActions(CurrentValue.DuplicateRows(), CurrentValue.DeleteRows()))

DuplicateRows doesn’t duplicate comments unfortunately so that’s still an issue, maybe they’ll add that!

1 Like