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 Reply
  • +1
    Certified Lead Developer
    over 5 years ago in reply to manisht209

    - "it works for me, i.e retains the previous selected value."

    You're right - I suppose what I should really say instead is "there's no way to disable the select all control, as it will not give the user their desired results" - but I never thought to try retaining the original selection.  I will try incorporating something similar into my current code.

    The following should take that into account, plus if the user clicks "select all" when nothing is selected yet, the selection will remain empty in this version.

    (Note that this code, as well as your code, both have a quirk when "select all" is clicked on a page containing 2 items - I can't find an easy way around this but it's probably not a big deal)

    saveInto: {
      a!save(
        local!gridSelection,
        a!gridSelection(
          pagingInfo: save!value.pagingInfo,
          selected: if(
            length(save!value.selected) > 2, /* override if "select all" 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 */
              {}
            )
          )
        )
      )
    }

Children
No Data