<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/discussions/f/user-interface/39043/cards-as-buttons-pattern-add-remove-from-array</link><description>I&amp;#39;m following the cards as a button layout. I have a series of &amp;quot;buttons&amp;quot; that are generated dynamically. 
 What I&amp;#39;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</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147710?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:28:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:20aa8230-c7ca-4e7e-97af-24fe9cccafce</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;No prob - would appreciate a verify-answer for any/all you found helpful, as always ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147709?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:26:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:32d48d86-b401-4ff9-a470-ecbec3aace0f</guid><dc:creator>jonathanf_kr</dc:creator><description>&lt;p&gt;Figured that out as well. Order of parameters is opposite in contains, and whereContains.&lt;/p&gt;
&lt;p&gt;Flipped those and it&amp;#39;s all working as expected now.&amp;nbsp; Thanks!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-- Posted before I saw your update.&amp;nbsp; But that was it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147708?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:24:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:58e8fb9d-337a-417e-82b3-97eddd7e9a4e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Also your WhereContains is backwards - I forget this all the time, too.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1746116643844v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147707?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:23:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:51c62730-d314-4667-87e4-0d51ee539995</guid><dc:creator>jonathanf_kr</dc:creator><description>&lt;p&gt;Always something so simple.&amp;nbsp; That was it.&amp;nbsp; Now I just need to update the logic for deselecting as it&amp;#39;s just removing the first item in the list not the one I&amp;#39;m actually clicking on.&amp;nbsp; Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147706?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:21:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0d066e93-1209-42eb-b743-aec55c534402</guid><dc:creator>jonathanf_kr</dc:creator><description>&lt;p&gt;Yeah I initially tried it without line 10.&amp;nbsp; That was just one of my later attempts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147705?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:21:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d1a4a520-22ef-4f9f-9b1f-eea9e7c7824c</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;the &amp;quot;link:&amp;quot; parameter expects a link, not an array of link.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1746116446685v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Fixing this issue seems to fix the issue I assume you&amp;#39;re having, at least when I try it.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/pastedimage1746116480493v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147704?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:20:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7194569c-9c20-4a8c-8ec2-6356306865ce</guid><dc:creator>jonathanf_kr</dc:creator><description>&lt;p&gt;No it&amp;#39;s not all the code I have. This is inside a a!foreach() loop.&amp;nbsp; local!itemNum is a calculated value based on the loop the number of columns in my layout etc to generate a grid of buttons.&amp;nbsp; This is all working as expected.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Layout is similar to below where each indivdual number is the a!cardLayout Component with the number as the text.&lt;/p&gt;
&lt;p&gt;| 1 | 2 | 3 |&lt;/p&gt;
&lt;p&gt;| 4 | 5 | 6 |&lt;/p&gt;
&lt;p&gt;| 7 |&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I set ri!selectedPeriods = {3, 5, 7 } manually then those corresponding &amp;quot;buttons&amp;quot; are highlighted correctly using the style parameter.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What I want now is that if I click on 3 then the index is removed from ri!selectedPeriods list and the button will change colors as a result.&lt;/p&gt;
&lt;p&gt;If I were to click on 6 then it will add the index to the selectedPeriods input and that now would change colors to the selected color.&lt;/p&gt;
&lt;p&gt;Whatever, I&amp;#39;m doing in&amp;nbsp;&lt;/p&gt;
&lt;p&gt;link: a!dynamicLink(...) is not working and I&amp;#39;m trying to understand what might be happening or a better way to accomplish this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147703?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:16:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:110cf778-4a4c-4dbd-a79e-b834084b0193</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="274702" url="~/discussions/f/user-interface/39043/cards-as-buttons-pattern-add-remove-from-array/147696"]In line 10, you are still using the local variable[/quote]
&lt;p&gt;I&amp;#39;d go one step further here, and point out that line 10 is irrelevant and not necessary.&amp;nbsp; When the dynamic link only does manual a!save() statements, the &amp;quot;value&amp;quot; parameter is not needed or used for anything, and (for clarity/readability/sanity) should be removed.&lt;/p&gt;
&lt;p&gt;Note: i&amp;#39;m not claiming this is causing the issue at play here, but (as we can see here) isn&amp;#39;t making anything any *less* confusing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147702?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:11:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7da7d890-79d3-4baa-86ef-f448de10c36b</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;It feels like this is not all the code you have.&lt;/p&gt;
&lt;p&gt;What value does that local!itemNum have?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147700?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 16:02:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4b0e56d3-948c-44e7-b0a4-9ffaba76fb1a</guid><dc:creator>jonathanf_kr</dc:creator><description>&lt;p&gt;I have tried both ways, with local! and ri!.&amp;nbsp; Neither work to update the array when clicking on the card button.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cards as Buttons Pattern: Add / Remove from array</title><link>https://community.appian.com/thread/147696?ContentTypeID=1</link><pubDate>Thu, 01 May 2025 15:30:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c265c14c-b8aa-43ee-89e0-2e55c7d36c95</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;In line 10, you are still using the local variable. Could that be the reason?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>