`table1.refresh()` doesn't refresh `table1.selectedRow` object

Hello,

I want to programmatically update a cell value in the selected row of a table. The table's dataSource is an array, and I've followed these steps:

  1. I modified the array.
  2. I refreshed the table using table1.refresh().

Now, the table displays the correct data, but the table1.selectedRow object still contains the previous values from before the modification.

Could someone please provide a solution?

Thanks in advance.

Best regards,
Sudip

Hi @Sudip_Bhattacharyya Thanks for reaching out! Would you mind sharing some screenshots so that we can investigate this?

It would be helpful to know what the table's data source is (temporary state, transformer, query, etc). So far, I haven't been able to reproduce this same behavior on my side

i have experienced the same issue, the selectedRow data doesnt updates until you re-select the row, my solution to this was not to use all selectedRow data but just the id, so in a transformer i can filter by the selectedRow id (because is the key that doesnt change by anything) and the transformet will update with any change made to the data source

Note: it happens if the table is in other container tab, like it happens to clearSelection() selectRow(), etc

Hello All,

The problem has been resolved. After table1.refresh(), I needed to navigate to the selected row using table1.selectRow(). The following code may be helpful:

let tempData = variableTableJSON.value;
const currentKey = table1.selectedRow.id;

tempData = tempData.map(row => {
  if (row.id === currentKey) {
    return {
        id: row.id,
        display_name: row.display_name,
        field_name: row.field_name,
        field_type: row.field_type,
        replace_formula: textAreaReplaceFormla.value
      }
    } else {
      return row
    }
  })

variableTableJSON.setValue(tempData);
table1.refresh();
table1.selectRow({mode: 'key', key: currentKey});

Best regards.

Thanks,

Sudip

1 Like