I am using a repeater to show pending requests from a dataset and I want the #soundcheckButton to expand only when the value of the ‘status’ field = APPROVED.
I have added the following code to the repeaters itemReady function, and it must be working in some way because the button element is set to collapse on page load but in the preview, it is showing up. The problem is that it’s expanding on all of the repeater items, instead of just those with the approved status.
export function requestsRepeater_itemReady($item, itemData, index) {
// Set the dismiss button to dismiss the appointment request when clicked.
$item("#cancelButton").onClick(async () => {
// Disable the dismiss and approve buttons.
$item("#cancelButton").disable();
// Dismiss the appointment request.
await cancelRequest(itemData, index, $w);
});
// Set the soundcheck button to show when request status is approved.
const requestApproved = (itemData.status = "APPROVED");
if (requestApproved) {
$item("#soundcheckButton").expand();
}
else {
$item("#soundcheckButton").collapse();
}
}
I’m not sure what’s causing this and how I should fix it. I did look at using the getCurrentItem API but that didn’t make sense to me when using a repeater that is connected to a dataset?