Hi,
why this function does not works?
export function table1_click(event, $w) {
$w("#dataset10").onReady(function () {
let pos = $w("#dataset10").getCurrentItemIndex();
let sq1 = $w("#table1").rows[pos]['team'];
console.log(sq1);
});
}
The content of the “sq1” variable is that of the collection (dataset10) and not that of the table on which I select the row with “table1_click” function.
Thanks and sorry for my bad english 
Claudio
The function doesn’t work because it doesn’t do anything. All it does is set a function to be run when the dataset is ready. Since the click routine is executed way after the dataset is ready, the function never runs.
You can just run the following code in the click handler:
let pos = $w("#dataset10").getCurrentItemIndex();
let sq1 = $w("#table1").rows[pos]['team'];
console.log(sq1);
If your page depends on the dataset for proper display, then you can add a dataset.onReady() handler to the page.onReady() handler, something like this:
$w.onReady(function () {
$w("#dataset10").onReady(function () {
// do page stuff with dataset
});
});
Good luck,
Yisrael
Hi, i tried the following code:
export function table1_click(event, $w) {
let pos = $w(“#dataset10”).getCurrentItemIndex();
let sq1 = $w(“#table1”).rows[pos][‘team’];
console.log(sq1);
}
but I continue to see the items of the collection and not those of the rows table on which I click;
Thanks
This line of code:
let pos = $w(" #dataset10 ").getCurrentItemIndex();
gets the current item index. You are using the result (pos) as an index into the table, so that’s the line in the table you will get.
Take a look at the Table Index example to see how to select a table row.
Excelentes as postagens!
Tem me ajudado muito mesmo.