How do you add a row in the middle of a table (not at the end) via a button?

Hello,
I have a table that depends on manual sort in order to function according to my needs.
But I need a way to add a row in the middle (for example, above row 11) via a button.

How can I do that?

Thank you!

I don’t think that’s possible.

The only way I’m aware to do something similar is to set some sorting that fulfills your needs and then use a button to fill in the data to appear where you want it.

If you share a dummy doc we can probably advise you on how to do that.

1 Like

Got it, I was hoping there was a workaround for this, even via the API, but I haven’t been able to find a solution. I’m familiar with using sort as a workaround, with an approach very similar to this: Use button to insert row below current row. I was just hoping there was some hidden trick I could leverage.

I’ll stick with sorting or change my approach then. Thank you so much for taking the time!

Hi Ford,

I do not know whether this will work, but have you tried duplicateRow()? When you manually duplicate row, it creates a row below the current row. If you’re lucky, it will work the same way when you use the formula.

In any case, here is some background on the various sequences in a table in Coda:

Enjoy
Rambling Pete

2 Likes

Brilliant idea! Unfortunately, I just tried it, and duplicateRow() behaves differently from right-clicking on a row and choosing ā€œDuplicate.ā€ In the first case, the row goes to the bottom. In the second case, it’s created right below the current row, as you said.

This difference breaks the logic of the column that uses the formula thisTable.Find(thisRow)

Here’s a dummy doc. I’ll keep trying to play with it so see if I can find a workaround. Thank you!

Try giving the row a sorting number and letter when is created (different that rowID).

Hello @Cristian_Nichifor ,

Can you be a bit more specific or show us a sample of your ā€˜solution’. If I understand correctly what you have in mind, I can’t see this type of numbering/lettering solve this when adding multiple records (with a button or automation), but I would love to see this working in a demo doc.

Greetings, Joost

Sorry for the late reply. I apologize I dont think I understand your approach. Wouldn’t that require the table to be sorted? My goal is to preserve the ability to manual sort via drag and drop.

If you want to avoid the automatic sort then the only way to achieve inserting a row is deleting half of the table, adding the row, then adding the half back

With pseudo code you could do something like this

  • Store the second half of the rows with Let
  • Add the new row
  • Duplicate the stored rows
  • Delete the stored rows
3 Likes

You can also use a similar approach to this, it allows manual sorting with buttons instead of drag & drop.

2 Likes

Thank you @Rickard_Abraham and @Pablo_DV. I’m aware of your approach @Pablo_DV, smart system, but I was looking to preserve the manual sorting experience for workflow reasons. I will go with something similar to what was suggested by @Rickard_Abraham .

Thanks to everybody for taking the time. I really appreciate it!

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.