I have a multiselect table and want to loop through the selected options. Here, I am using a for loop and trigger selectrow on each index, I do this because I want to not only use the respective table data, but also other data that is dependent on the selectedrow property (transformers (Please verify whether this also changes upon using selectrow and other queries).
Now, when I do this, we loop so fast through the table using selectrow that there is not enough time it seems like to access the selectedrow.data, how would I solve this? Could I for example implement something such that the code only continues running when all queries dependent on selectRow (event handlers etc.) are done running?
Help is much appreciated!
Simplified example:
async function handleBulkApproval() {
const selectedRows = table1.selectedRow.data;
for (const row of selectedRows) {
// console.log(row)
let a = await table1.selectRow(1)
console.log(table1.selectedRow.data)
let b = await table1.selectRow(2)
console.log(table1.selectedRow.data)
....
Yes, it is not possible to set selectRow then access it immediately. But you should have the underlying data for the table from the data, and you should get the data from there. If not, I suggest capturing the table data in a variable so you can access it.
Okay, good to know, is there however a way that I can await the selectRow till the data is accessible?
The reason being is because I have a transformer, that depends on another transformer, that in turn depends on data from the selectedRow. If I could trigger the rowclick that loads all the data in the aforemetioned, selectRow would be a great solution. Before rewriting everything (which I now see as the solution), I wanted to check if there are any other ways.
You can try the "Keep variable references inside the query in sync with your app." option, just note that this may not be very performant and that it may not work well with transformers due to some legacy backward compatibility issues.