HI! I have amenities list which are setup via dynamic links with booleans to be a yes/no for each. Current setup below, but the client wants to only show amenities which are ticked yes. This would mean there would be gaps if I hide the unticked elements. I could use boxes and collapse them, but I think if there is uneven amenities in each column it will look weird.
Therefore I think repeaters would be the way to go. How would I add the correct data field name (ie air conditioning) to each repeater container, and how do I collapse a repeater container if the boolean isn’t true? Thank you!
Currently, as repeaters are in their early stages, they do not support user input components.
We know that this is requested and doing everything we can make it better
Thank you. But how to collapse a repeater container when they dont have individual ids. I know how to check if value is ===true, but if I have different text in each repeater ie air conditioning then barbeque then towels then TV, how do I collapse if boolean isnt true?
Use ’ onItemReady ’ for your repeater… for example:
Inside of it’s callback, each element ID refers to the one in the current item.
So, if you have three items in the repeater, each has #text1 and #text2, then for each item, the callback function will run, you just need to adjust the condition, something like:
export function repeater1_itemReady($w, itemData, index) {
const amenityName = itemData.amenity;
if ($w(#checkbox-${amenityName}).value === false) {
// Hide elements in this specific repeater item
$w(‘#text1’).collapse();
$w(‘#text2’).collapse();
}
}
NOTE: i’ve assumed naming for the checkboxes (e.g. ‘#checkbox-aircon’) and fields in database (e.g amenity).
export function repeater1_itemReady($w, itemData, index) {
const currentItem = $w("#dataset1").getCurrentItem();
if (currentItem[itemData.amenity] === true) {
$w("#text1").collapse();
}
}
I’m assuming that, in the database that is connected to the repeater, you have a field call ‘amenity’, which can be ‘barbeque’, ‘airConditioning’, etc.
Then, ‘currentItem[itemData.amenity]’ will read the corresponding amenity (if the current item of the repeater is ‘barbeque’ than it will be ‘barbeque’).
So you only need this code once, but you need to have the amenities listed in the database that is connected to the repeater.
I’m trying to do the same thing on my site, did you manage to make the code work? If so, could you share it please? I don’t understand that much yet, so you will help me a lot