<?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>Select only one choice in grid selection</title><link>https://community.appian.com/discussions/f/user-interface/7274/select-only-one-choice-in-grid-selection</link><description>Hello, I&amp;#39;d like to be able to select only one choice in a grid selection at the same time. Is there a way to force that? 
 OriginalPostID-202357 
 OriginalPostID-202357</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/112771?ContentTypeID=1</link><pubDate>Mon, 15 May 2023 19:50:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9be2c588-a11a-40cf-b2da-803a7d92ea19</guid><dc:creator>chandler.corales</dc:creator><description>&lt;p&gt;I found success w/ this use case in 23.1 by mimicking the above code w/ a few changes shown below. It mainly just adds a bit more handling for when you&amp;#39;re de-selecting a row.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!gridField(
    /*...*/
    selectionValue: local!gridSelection,
    selectionSaveInto: {
        local!gridSelection,
        if(
            a!isNullOrEmpty(local!gridSelection),
            {
                a!save(local!gridSelection, {}),
                a!save(local!selectionIndex, {})
            },
            {
                a!save(local!selectionIndex, reverse(local!gridSelection)[1],
                a!save(local!gridSelection, local!selectionIndex)
            }
        ),
        /*more saves*/
    },
    /*...*/
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/82764?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 15:21:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c94f1dba-a9d9-46da-9acd-56ac5f424ac5</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This is a very old thread, and several of the &lt;a href="/discussions/f/user-interface/7274/select-only-one-choice-in-grid-selection/46008#46008"&gt;original comments&lt;/a&gt; contain robust and still-working solutions to this. Though with the advent of the 19.2+ paging grid, all of this is a bit out-of-date.&amp;nbsp; For instance, designers now have the ability to turn off selection for all rows other than a single selected row, among other possible options.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/82763?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 15:10:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b141b49b-9d0b-4f53-8478-947720d1bba9</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;I don&amp;#39;t think this is correct - your grid will error if you deselect a row because the if() condition will return false and the second save won&amp;#39;t have 2 values.&lt;/p&gt;
&lt;p&gt;There&amp;#39;s actually a recipe in the documentation that describes how to do this:&amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/latest/recipe-limit-rows-to-one.html"&gt;docs.appian.com/.../recipe-limit-rows-to-one.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/82760?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 14:09:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1e8ae55e-9cc3-404d-a583-6f11d164b3aa</guid><dc:creator>Jaume</dc:creator><description>&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;selectionValue: local!&lt;span&gt;gridSelection&lt;/span&gt;,&lt;br /&gt; selectionSaveInto: {&lt;br /&gt;&amp;nbsp; local!&lt;span&gt;gridSelection&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; if(&lt;br /&gt;&amp;nbsp; &amp;nbsp; length(local!&lt;span&gt;gridSelection&lt;/span&gt;)=1,&lt;br /&gt;&amp;nbsp; &amp;nbsp; local!&lt;span&gt;gridSelection&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; a!save(local!&lt;span&gt;gridSelection&lt;/span&gt;, local!&lt;span&gt;gridSelection&lt;/span&gt;[2])&lt;br /&gt;&amp;nbsp; )&lt;br /&gt; },&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/46008?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2017 13:55:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a33a5a63-f237-4ddd-9153-78af450cff04</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;&lt;a href="/members/manisht209"&gt;manisht209&lt;/a&gt; - &amp;quot;it works for me, i.e retains the previous selected value.&amp;quot;&lt;/p&gt;
&lt;p&gt;You&amp;#39;re right - I suppose what I should really say instead is &amp;quot;there&amp;#39;s no way to disable the select all control, as it will not give the user their desired results&amp;quot; - but I never thought to try retaining the original selection. &amp;nbsp;I will try incorporating something similar into my current code.&lt;/p&gt;
&lt;p&gt;The following should take that into account, plus if the user clicks &amp;quot;select all&amp;quot; when nothing is selected yet, the selection will remain empty in this version.&lt;/p&gt;
&lt;p&gt;(Note that this code, as well as your code, both have a quirk when &amp;quot;select all&amp;quot; is clicked on a page containing 2 items - I can&amp;#39;t find an easy way around this but it&amp;#39;s probably not a big deal)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="perl"&gt;saveInto: {
  a!save(
    local!gridSelection,
    a!gridSelection(
      pagingInfo: save!value.pagingInfo,
      selected: if(
        length(save!value.selected) &amp;gt; 2, /* override if &amp;quot;select all&amp;quot; was clicked: retain original value */
        local!gridSelection.selected,
        index(
          save!value.selected,
          length(save!value.selected), /* for normal clicks, this will correctly capture the first or any subsequent click, as well as a de-select click */
          {}
        )
      )
    )
  )
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/45989?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2017 05:36:35 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6fccee45-a948-402f-b921-97718d3db08e</guid><dc:creator>aloks0189</dc:creator><description>I Agree that there should be an out of the box option to handle it, but we should also accept this fact, Appian currently releasing pretty huge and great updates into each one of their releases. And for 17.2 they have majorly focused on Better UI designing, Decision and easy integration approach. They might have this also in their mind, and in future they may release an out of the box for this as well. For example they have automate File Upload component for multiple in a decent way in 17.2 release, in the same way they may release these features also in upcoming releases, but can&amp;amp;#x27;t be sure. &lt;br /&gt;
&lt;br /&gt;
But i feel, if they provide everything OOTB then there won&amp;amp;#x27;t be any challenges, difficulties and won&amp;amp;#x27;t be anything to learn for the developer, and the designer won&amp;amp;#x27;t have understanding about what&amp;amp;#x27;s going on behind the screen, and however we can handle these scenarios by writing our own logic also.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/45987?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2017 05:10:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:39472deb-2189-4eb7-a183-d2f94a6211bb</guid><dc:creator>Shivam Gupta</dc:creator><description>ohh yes i guess I forgot to add this condition.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/45986?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2017 01:19:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:34dcc63a-26af-4a87-8031-a3cdcf44fea3</guid><dc:creator>manisht209</dc:creator><description>&lt;p&gt;Hey Mike,&lt;/p&gt;
&lt;p&gt;Agree that there should be an out of the box option to handle it in an elegant manner.&lt;/p&gt;
&lt;p&gt;Also, When you say ,&amp;quot;Note that there&amp;#39;s currently no way to avoid the behavior where clicking the &amp;quot;select all&amp;quot; control causes the last item on the current page to be selected, as mentioned above&amp;quot;. Did you try the code I gave above.&lt;/p&gt;
&lt;p&gt;because it works for me, i.e retains the previous selected value.&lt;br /&gt;For this reason only I wont directly index the length but use it to see if I have to index the first or the last one&lt;/p&gt;
&lt;p&gt;see the lines -&lt;br /&gt;&lt;pre class="ui-code" data-mode="html"&gt;if(
  --If below is true it means you have clicked select all
  length(
    local!gridSelection.selected
  ) &amp;gt; 2,
  --logic to retain the older value
  index(
    local!gridSelection.selected,
    1,
    &amp;quot;&amp;quot;
  ),
  --Logic to retain the new value
  index(
    reverse(
      local!gridSelection.selected
    ),
    1,
    &amp;quot;&amp;quot;
  )
)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;please let me know if this helps&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/45973?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2017 13:29:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0d63ce4b-4999-4fc3-932e-6838bb9e5c42</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I find the official appian SAIL recipe approach of throwing a validation error to be unnecessary and kinda clunky, no offense, and to be quite honest it doesn&amp;#39;t make much sense to me that after all this time they&amp;#39;ve never engineered the paging grid component to contain a &amp;quot;singleSelect&amp;quot; parameter (or alternatively &amp;quot;maxSelections&amp;quot; for greater flexibility) where the &amp;quot;select all&amp;quot; control will be hidden when # of selections is restricted (or at least, smaller than the current page size).&lt;/p&gt;
&lt;p&gt;Out of necessity I&amp;#39;ve developed the following code which handles the single-select use case pretty strongly IMHO, and it has been refined quite a bit over the past 3 years or so:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;saveInto: {
  a!save(
    local!gridSelection,
    a!gridSelection(
      pagingInfo: save!value.pagingInfo,
      selected: index(
        save!value.selected,
        length(save!value.selected),
        {}
      )
    )
  )
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This code does similar to what some of the prior examples here suggest, though a bit more compact, and automatically handles the use case of de-selecting the current selected item.&amp;nbsp; Note that there&amp;#39;s currently no way to avoid the behavior where clicking the &amp;quot;select all&amp;quot; control causes the last item on the current page to be selected, as mentioned above - this is probably the single strongest reason there really needs to be an OOB control for restricting the number of selections.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/45966?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2017 11:22:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:351979f9-8838-485c-9dca-9bf905341223</guid><dc:creator>manisht209</dc:creator><description>Hi shivamg,&lt;br /&gt;
&lt;br /&gt;
there are two things,&lt;br /&gt;
&lt;br /&gt;
1. When you check the select all option more than once the selection value will always toggle between the last and the second last option, this is because the items will be appended sequentially (which are not already present in the selection). &lt;br /&gt;
&lt;br /&gt;
To give a consistent behavior I restricted it to the previous value when selecting all i.e selection &amp;gt; 2.&lt;br /&gt;
&lt;br /&gt;
2. If you deselect an already selected item, the grid will fail to render so we explicitly need to set it to an uninitialized array &amp;quot;{}&amp;quot;.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/45965?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2017 10:51:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ebe032e8-fb3b-4610-8acd-a0a9a64edd49</guid><dc:creator>Shivam Gupta</dc:creator><description>Hi mokhtarc970,&lt;br /&gt;
         You can do by making some changes in the saveInto parameter of grid as follows:&lt;br /&gt;
saveInto: {&lt;br /&gt;
                  local!gridSelection,   //you create a variable to save grid selection data&lt;br /&gt;
                  a!save(&lt;br /&gt;
                    local!selectedId,    //you save the selected value to another local variable &lt;br /&gt;
                    reverse(local!gridSelection.selected)[1]     //you reverse the local!gridSelection.selected to get the first value as the latest value&lt;br /&gt;
                  ),&lt;br /&gt;
                  a!save(      // set the local value as null&lt;br /&gt;
                    local!gridSelection.selected,   &lt;br /&gt;
                    null&lt;br /&gt;
                  ),&lt;br /&gt;
                  a!save(     // reset the value to previous variable&lt;br /&gt;
                    local!gridSelection.selected,&lt;br /&gt;
                  local!selectedId&lt;br /&gt;
                  )&lt;br /&gt;
       }&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/45956?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2017 07:23:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ff74d9b7-7944-49cb-b1f5-30a74a935d34</guid><dc:creator>manisht209</dc:creator><description>&lt;p&gt;I had a similar requirement and didn&amp;amp;#x27;t want to give a validation error message.&lt;br /&gt; The intention is to automatically change the selection to the latest selected value in the grid. When User selects check all it persists the value that was selected before this operation.&lt;br /&gt; &lt;br /&gt; This is done as below in Grid&amp;amp;#x27;s SaveInto&lt;br /&gt; &lt;br /&gt;&lt;pre class="ui-code" data-mode="html"&gt;saveInto: {
  local!gridSelection,
  a!save(
    local!gridSelection.selected,
    if(
      rule!APN_isEmpty(
        local!gridSelection.selected
      ),
      {},
      if(
        length(
          local!gridSelection.selected
        ) &amp;gt; 2,
        index(
          local!gridSelection.selected,
          1,
          &amp;quot;&amp;quot;
        ),
        index(
          reverse(
            local!gridSelection.selected
          ),
          1,
          &amp;quot;&amp;quot;
        )
      )
    )
  )
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/29431?ContentTypeID=1</link><pubDate>Wed, 23 Mar 2016 22:34:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b42ef487-5e8b-49b4-a999-6fe489f5891c</guid><dc:creator>Lakshmi Meyyappan</dc:creator><description>This SAIL Recipe should help too: &lt;a href="https://forum.appian.com/suite/help/16.1/SAIL_Recipes.html#Limit_the_Number_of_Rows_in_a_Grid_That_Can_Be_Selected"&gt;forum.appian.com/.../SAIL_Recipes.html&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/29422?ContentTypeID=1</link><pubDate>Wed, 23 Mar 2016 18:37:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b59a3bad-e272-4818-acef-bd7d77bb35e0</guid><dc:creator>vishnuv</dc:creator><description>You can try the below approach:&lt;br /&gt;In validations of a!gridField() component, use the logic &lt;br /&gt;&lt;br /&gt;if(count(local!gridSelection.selected)&amp;gt;1, &amp;quot;You can select only one choice&amp;quot;, null)&lt;br /&gt;&lt;br /&gt;Also in saveInto, use the logic&lt;br /&gt;&lt;br /&gt; {&lt;br /&gt;    local!gridSelection,&lt;br /&gt;     if(&lt;br /&gt;      count(local!gridSelection.selected)&amp;gt;1,&lt;br /&gt;       {},&lt;br /&gt;      a!save(local!selectedEmployeeId, index(save!value, &amp;quot;selected&amp;quot;, null))&lt;br /&gt;      )&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Where local!gridSelection is &lt;br /&gt;a!gridSelection(&lt;br /&gt;    pagingInfo: a!pagingInfo(&lt;br /&gt;      startIndex: 1,&lt;br /&gt;      batchSize: 20,&lt;br /&gt;      sort: a!sortInfo(&lt;br /&gt;        field: &amp;quot;fieldName&amp;quot;,&lt;br /&gt;        ascending: true/false&lt;br /&gt;      )&lt;br /&gt;    )&lt;br /&gt;  )&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Select only one choice in grid selection</title><link>https://community.appian.com/thread/29415?ContentTypeID=1</link><pubDate>Wed, 23 Mar 2016 16:28:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bbd496ac-167f-4908-8727-211faf766b44</guid><dc:creator>sagarl511</dc:creator><description>It is possible by adding validation at grid level to check if gridSelection.selected has more than one value or disabling submit buttons if user has selected more than two rows.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>