How can I check to see if a single repeater item is selected?
My objective is to show an element IF the repeater item is selected onClick. ELSE it needs to be hidden.
The repeater item is set to toggle and having difficulty show/hiding the element when only one of the repeater items is selected. What condition could I use to build the logic to show that element ONLY when the selected repeater item is selected (or hidden if not selected)?
A few questions⌠What exactly do you mean by 'if a single repeater item is selected" --an operational definition would help. Posting your .rp file here would be much better. Specifically, what is a ârepeater itemâ? Checkbox? Button? The repeater row? The entire repeater widget? What is the importance of âa single itemâ versus more âitemsâ which might be selected? Is it the case that your âelementâ should be hidden if less than 1 or greater than 1 ârepeater itemsâ are selected? Or, would it be shown if at least one repeater item is selected? For that matter, can more than one repeater item be selected at once?
What do you mean by âshow an elementâ --what do you mean, exactly, by âan elementâ? A specific widget? Is the âelementâ inside or outside the repeater?
In general, you could track and control this in the repeaterâs OnItemLoad event. The first Case could be a condition like, If [[Item.IsFirst]] is equal to "true" set OnLoadVariable equal to 0 (or use some other global variable or a hidden text widget) which would initialize your count of selected items/rows. Then you could have a following Case with a condition like, If [[Item.SelectionState]] is equal to "true" set OnLoadVariable to [[OnLoadVariable + 1]] and Set selected of MyRepeaterItem to "true" --where âSelectionStateâ is a column in your repeater.
Once the entire repeater is loaded, youâll have a count of how many repeater items are selected. You can then use the repeaterâs OnLoad event to handle what to do based on the value of your counter (OnLoadVariable in this example.) So, something like, If value of OnLoadVariable is equal to 1 show MyElement, Else hide MyElement.
Clicking on the repeater item would Update This Row to set the value of SelectionState to selected state of This. If you do this instead of just toggling the selection state then your repeater dataset can be used to track, control, and count how many items are selected.
My apologies for being so vague. Essentially, I want to show something if a repeater row is selected. Otherwise, donât show it.
Iâve included an example.
In this example, when a âTicket List Itemâ is selected I want to show the âList Item Selectorâ. Only one âTicket List Itemâ can be selected at a time and so the same would apply for the âList Item Selectorâ
Please look at the file and let me know if there is anything else I can help explain better.
Thank you for posting the .rp file, totally helps me understand whatâs going on.
A few little tweaks and this works. I duplicated your page in this updated file with these changes:
I moved the âList Item Selectorâ to the left so it can actually appear in the dynamic panel that contains the repeater. (The repeater will grow to show it but the dynamic panel is set to a fixed width which is too narrow to show the list selector.)
I made the âList Item Selectorâ selectable and shown when selected by styling its selection state to 100% opacity and its normal state to 0% opacity. This is mostly just a different way to show/hide a widget. I could have kept your âList Item Selectorâ as is and add a Show/Hide action to the OnClick event for the âTicket List Itemâ group. But, since it was already in the âTicket List Itemâ group and the selection state for the group is toggled when clicked, the selection state of âList Item Selectorâ is already toggled, so this is an easy way to take advantage of that.
To ensure that only one âList Item Selectorâ is selected at once, I assigned it a selection group, just like you did for the âTicket List Itemâ group.