OnCurrentIndexChange handler triggers before I select a row on the table

Hi,

I’m trying to get the row data from a table which is connected to a dataset. So as per the this article , since, I need the whole data of the selected row, I’m using OnCurrentIndexChange event handler to get the selected row’s data from the dataset. But for some strange reason, the first row item will always be triggered on the load of the table/page.

Basically, the first row data will be selected on the load of the page/table. Is this a bug or am I doing something wrong?

Any help will be greatly appreciated.

Thanks,
Jilu

Though I couldn’t get to work with OnCurrentIndexChange handler. But I found a work around by which I could fix this bug/issue for my application.

Solution:

Instead of using OnCurrentIndexChange handler of the dataset, I used OnSelectRow event handler to get the row index of the table and used that index to get the whole row data from the dataset. More on this get method, you can find here .

Below is the code for your reference:

export function tblCustomerList_rowSelect(event) {
    $w("#dsCustomer").getItems(event.rowIndex, 1)
        .then(result => {
 let selectedRow = result.items[0];
            console.log(selectedRow);

 if (selectedRow !== null) {
 let returnObj = {
 "name": selectedRow.name,
 "id": selectedRow._id
                }
                wixWindow.lightbox.close(returnObj);
            }
        })
}

Hope this will be helpful for people who are stuck with such kind of issue in wix.

Thanks,
Jilu