Select only one choice in grid selection

Hello,

I'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

  Discussion posts and replies are publicly visible

Parents
  • 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't make much sense to me that after all this time they've never engineered the paging grid component to contain a "singleSelect" parameter (or alternatively "maxSelections" for greater flexibility) where the "select all" control will be hidden when # of selections is restricted (or at least, smaller than the current page size).

    Out of necessity I'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:

    saveInto: {
      a!save(
        local!gridSelection,
        a!gridSelection(
          pagingInfo: save!value.pagingInfo,
          selected: index(
            save!value.selected,
            length(save!value.selected),
            {}
          )
        )
      )
    }

    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.  Note that there's currently no way to avoid the behavior where clicking the "select all" 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.

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    Hey Mike,

    Agree that there should be an out of the box option to handle it in an elegant manner.

    Also, When you say ,"Note that there's currently no way to avoid the behavior where clicking the "select all" control causes the last item on the current page to be selected, as mentioned above". Did you try the code I gave above.

    because it works for me, i.e retains the previous selected value.
    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

    see the lines -

    if(
      --If below is true it means you have clicked select all
      length(
        local!gridSelection.selected
      ) > 2,
      --logic to retain the older value
      index(
        local!gridSelection.selected,
        1,
        ""
      ),
      --Logic to retain the new value
      index(
        reverse(
          local!gridSelection.selected
        ),
        1,
        ""
      )
    )


    please let me know if this helps

  • 0
    Certified Lead Developer
    in reply to manisht209
    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't be sure.

    But i feel, if they provide everything OOTB then there won't be any challenges, difficulties and won't be anything to learn for the developer, and the designer won't have understanding about what's going on behind the screen, and however we can handle these scenarios by writing our own logic also.
Reply
  • 0
    Certified Lead Developer
    in reply to manisht209
    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't be sure.

    But i feel, if they provide everything OOTB then there won't be any challenges, difficulties and won't be anything to learn for the developer, and the designer won't have understanding about what's going on behind the screen, and however we can handle these scenarios by writing our own logic also.
Children
No Data