I'm following the cards as a button layout. I have a series of "buttons" that are generated dynamically.
What I'm trying to achieve is that my component tracks which buttons are currently selected.
There is a rule input which is a list of integers of the selected buttons. I would like when the button is clicked for the id of the button to be added or removed from the list and the button card will change colors from selected to not selected and back.
Currently the coloring works when setting the selected values by default but I cannot get the values to update when clicking on the "button".
a!cardLayout( contents: { a!richTextDisplayField( value: { a!richTextItem(text: local!itemNum) }, align: "CENTER" ) }, link: { a!dynamicLink( value: local!selectedPeriods, saveInto: a!save(ri!selectedPeriods, if( contains(ri!selectedPeriods, local!itemNum), remove( ri!selectedPeriods, whereContains(ri!selectedPeriods, local!itemNum) ), append(ri!selectedPeriods, local!itemNum) ) ) ) }, height: "AUTO", style: if( contains(ri!selectedPeriods, local!itemNum), "ACCENT", "STANDARD" ), shape: "ROUNDED", padding: "NONE", marginAbove: "NONE", marginBelow: "EVEN_LESS", showBorder: false, borderColor: "ACCENT", showShadow: true )
Discussion posts and replies are publicly visible
In line 10, you are still using the local variable. Could that be the reason?
Stefan Helzle said:In line 10, you are still using the local variable
I'd go one step further here, and point out that line 10 is irrelevant and not necessary. When the dynamic link only does manual a!save() statements, the "value" parameter is not needed or used for anything, and (for clarity/readability/sanity) should be removed.
Note: i'm not claiming this is causing the issue at play here, but (as we can see here) isn't making anything any *less* confusing.
Yeah I initially tried it without line 10. That was just one of my later attempts.