Unable to retrieve data on a button_click function

I have a table connected to a dataset.
When I select a row in a table, I have text objects that are showing the value of the selected row in the table.
I update few fields of the selected row with a submit button
This block is working well.
The code is part a $w.onReady(function () {}

I now want to be able to send an email when clicking to the submit button
I have a second block with:
export function buttonValidateFlight_click(event, $w) {}

The problem is my data parts of the selected line are unknown/undefined.
I can’t include the button_click function in the $w.onReady(function ()

How can I retrieve my selected data in the button_click function ?

Thanks for your help.
Regards,
Pierre-yves

Hi,
The way to get the table’s selected row is to declare a variable outside the scope of onReady() and to store the selected row in that variable. this way the var will be also available in button_click.
For example:

let selectedRow;

$w.onReady(function () {
	selectedRow = $w('#table1').rows[0];
});

export function button1_click(event, $w) {
	//selectedRow is available!
} 

Sounds good !!!
It works
many thanks for your help Ohad

Regards,
Pierre-yves

Dear Ohad,
Still on this issue, I’ve got a question…
When I select a specified row, how can I manipulate the dedicated row in the dataset ?
For example, I select a row and I want to update in the dataset the value of a field.
Or I want in the code to capture the value to a field to send it via email.
Thanks for your help
Regards,
Pierre-yves

In the documentation for Table’s onRowSelect() you can see an example how to retrieve the selected row.