selectedRow returns no value

Hi,

I added a new table cell value for an empty cell (I did that by making the column editable), and the value I provided is not reachable using selectedRow. I need that to get the value in order to configure the save and update function.

Thanks in advance for any help or advice!

1 Like

You need to click "save" for the edits to be applied to the data source:

alternatively, I think unsaved edits should also show up in table_name.changesetArray or .changesetObject instead of table_name.selectedRow

4 Likes

Hey @eekmv ,

Thanks for sharing the screenshot—got it. The core issue is that your UPDATE query is using hard-coded/input values. When you edit directly in a Retool Table, you should read the edits from the table’s change set and pass those into your query instead: table1.changesetArray (array of changed rows) or table1.changesetObject (object keyed by primary key).

What to do

1) Make sure the table has a primary key set

  • In the Table settings, set Primary key to the unique ID column. Without this, the change set won’t map rows correctly.

2) Use the change set in your update flow

Option A — Row-by-row updates (simple & reliable)

// JS query to run on "Save changes" or a button click
const updates = table1.changesetArray;  // [{ id: 123, status: 'Paid', amount: 99.5 }, ...]
if (!updates.length) return utils.showNotification({ title: 'No changes to save.' });

for (const row of updates) {
  await updateRow.trigger({
    additionalScope: { row }  // pass the whole row to the SQL query
  });
}

table1.clearChangeset();
utils.showNotification({ title: 'Updates saved successfully.' });

SQL for updateRow (example Postgres)

UPDATE orders
SET
  status = {{ row.status }},
  amount = {{ row.amount }}
WHERE id = {{ row.id }};

Option B — Iterate over changesetObject (when you prefer keyed access)

const updatesObj = table1.changesetObject; // { "123": { id: 123, status: 'Paid', ... }, ... }
const ids = Object.keys(updatesObj);
if (!ids.length) return;

for (const id of ids) {
  const row = updatesObj[id];
  await updateRow.trigger({ additionalScope: { row } });
}

table1.clearChangeset();

  • Refresh data after save (e.g., getOrders.trigger()), then table1.clearChangeset() to reset the UI.

If you share your table schema (column names + primary key) or your current SQL, I can tailor the exact UPDATE statement for your case.

2 Likes

@WidleStudioLLP @bobthebear thanks a lot for a help! :raised_hands:

2 Likes