Table Add New not working if table has no .data

I have a table/subtable relationship in my app. I download all subtable records at app start and use a JSON SQL query to filter the subtable to related records.

When I add a new record to the table there will not be any related records in the subtable yet and I want to add some. But if there aren't any there yet, no dice. If I am adding a subtable record to where there already is at least one, then it works fine.

I tried using a filter instead to "empty" the table and added a record and that also works fine.

So it seems that if the .data property is empty, even if all of the .columns are properly configured, add new breaks.

1 Like

Thanks for flagging this behavior, @bradlymathews I see what you mean. I will create an internal bug report for this 🙂

1 Like

Hi there. I'm facing the same issues. I cannot add a new row to a table when there's no data in the table.
Even if i added list of columns through "Column Settings" - it doesn't help.
I have seem this issue on the forum raised multiple times so maybe it makes sense to invest some dev time into this.

Creating a separate modal to add records is time-consuming, especially when Add Row functionality works perfectly well for tables already initialized with data

Hi @sokol8 Thanks for reaching out! We actually just shipped a fix for this bug. Are you using Retool on Cloud or self-hosting?

Hi Tess. Great to hear you fixed it!

I'm using Retool on Cloud. In the end I used a hack posted in one of the forum topics.
Is it possible to read docs on how to do it properly now?

Hi @sokol8! Glad you found a solution.

If your table already has the columns set, then you can go ahead and add new rows. You'll just want to make sure at least 1 of your columns is marked as editable.

If you don't have any columns defined yet, you may need to provide the default column data to your table:

I don't understand how to set the initial columns.

I have a table which displays data based on a selection in another table. The table may show zero or more records. When there are zero records I am unable to add new records as the add button opens with an empty set of columns. If there is a row of data, all works as expected.

Is there a way for me to keep these columns there all the time? When the table is empty no columns are defined for the table, when the table fills with data there are columns defined, along with all the extra details I added to each of the columns.

How do I keep these columns active regardless of the current number of rows in the table? Thus so the table can always add a new row.

Hi @brettski! Would it work for your use case to hardcode the column names for the cases where there are no rows, like this:

1 Like

Never thought of that, seems too simple.
Used a placeholder data row instead of [] and it worked like a charm. Thanks for the suggestion! Not the cleanest approach, but certainly usable.

One issue with the table and how it handles data @Tess is when a column may be optional and the user decides not to add that row for the first record. Now that row can never be added as it will not show.

Having a dynamic set of rows is useful for getting things going quickly, but its usefulness breaks down as you get into it.

I have the same problem. Although adding an empty data row can work as a workaround, it really appears when you run the app as a row, instead of the "No rows found" empty state. It's certainly confusing that you need to add a fake row in order to be able to add the first row. In my case, I'm using an OpenAPI query, which has the schema. Using that schema would be useful.