Update particular item on particular repeater list based on the data from database


In the above repeater, there are two buttons “Cancel” and “Return/Refund”.
At first only Cancel button will be shown and Return/Refund button will be hidden.


But when the refund-button is set to true in the dataset, the Cancel button should be hidden and Return/Refund button should be shown of that particular list.

Any idea on how to achieve this?

$w(“#repeater1”).forEachItem(($item, itemData, index) => {
let productname = itemData.productName;
let orderid = itemData.title;
let size = itemData.size;
let color = itemData.color;
wixData.query(“AdminOrders”).eq(“title”, orderid)
.and(wixData.query(“AdminOrders”).eq(“productName”,productname))
.and(wixData.query(“AdminOrders”).eq(“size”, size))
.and(wixData.query(“AdminOrders”).eq(“color”, color))
.find()
.then( (results2) => {
let refundbutton = results2.items[0].refundButton;

if (results2.items[0].refundButton){
$w(‘#button6’).show();
$w(‘#button5’).hide();
}
})
})
This code do not work

Have a read of this previous forum post as it may shed a bit of insight for you.
https://www.wix.com/corvid/forum/community-discussion/empty-checkbox-in-database-is-not-false

@givemeawhisky
Thanks that helped little,
but I am facing another problem,

$item(“#button5”).hide(); // button5 is the cancel button

I am using this in my repeater but it do not work
$w(’ #button5 ').hide(); // This code is applied to all the list in the repeater,

If I just want to hide the button of third index only, how should I do it??

@dhamaalyash

There are lots of previous forum posts that you can look at for help…
https://www.wix.com/corvid/forum/community-discussion/conditionally-show-hide-a-button-on-a-repeater-control
https://www.wix.com/corvid/forum/community-discussion/hide-button-in-repeater-based-on-field-used
https://www.wix.com/corvid/forum/community-discussion/fixed-show-hide-items-in-a-repeater
https://www.wix.com/corvid/forum/community-discussion/hide-show-items-in-repeater
https://www.wix.com/corvid/forum/community-discussion/hide-repeater-contents-based-on-data
https://www.wix.com/corvid/forum/community-discussion/solved-i-need-help-showing-and-hiding-an-element-inside-a-repeater
https://www.wix.com/corvid/forum/community-discussion/hide-and-show-a-button-in-repeater-based-on-a-condition
https://www.wix.com/corvid/forum/community-discussion/display-certain-buttons-in-repeater-onitemready-itemdata