How can I update a data from dataset that is connected to a repeater?

I am new to wix. I have been looking for the solution and attempted to fix it myself for a few days but I could not still fix it. Thus, I would like to look for help from here. Thanks in advance.

Here is the background -
In one of my member page, I have set up a repeater that is connected to a dataset. It is designed to display a list of records (as a repeater) from the dataset on the filter of the member’s email address. One of the functions in this page is to allow the member to update the specific record in the repeater when he clicks a button on that specific record.

Here is the issue -
when I click whichever button in the repeater, the event handler of that button always shows the same data from the dataset (while I can find the correct itemId from the event context). What I want to do in that handler is that when the button is clicked, I use the itemId captured from the event context and update that record in the dataset to set that record’s status (which is a text field) to “Approved”. How can I do that?

Here is the code I am stuck at -
export function button2_click(event) {
// Add your code for this event here:
let id = event.context.itemId; //this ItemId is correct
let count = $w( “#dataset1” ).getTotalCount();

let item = $w( “#dataset1” ).getCurrentItem();
console.log(item); //this always displays the same item regardless of which button I click. I tried to loop through the dataset with getItems() and next(). Still I could not find the right way to do it.
//Set the status to “Approved” of that item

}

Hello David,

i think you have the same issue, like this user here…
https://www.wix.com/corvid/forum/community-discussion/changing-the-value-of-database-from-repeater

Thanks, Dima. I got the itemId already. So I just need to use WixData.update() to update the corresponding data. Correct?

If you want to UPDATE data, probably YES :grin:
I think you could also use SAVE, but not sure.

@russian-dima Thanks. I am trying that but it keeps failing. I suspect I did not put in the right collection name. I am using the collection through a dataset named #dataset1. And I tried a few different name and it could not work. Do you know about it?