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
  • Hi mokhtarc970,
    You can do by making some changes in the saveInto parameter of grid as follows:
    saveInto: {
    local!gridSelection, //you create a variable to save grid selection data
    a!save(
    local!selectedId, //you save the selected value to another local variable
    reverse(local!gridSelection.selected)[1] //you reverse the local!gridSelection.selected to get the first value as the latest value
    ),
    a!save( // set the local value as null
    local!gridSelection.selected,
    null
    ),
    a!save( // reset the value to previous variable
    local!gridSelection.selected,
    local!selectedId
    )
    }
Reply
  • Hi mokhtarc970,
    You can do by making some changes in the saveInto parameter of grid as follows:
    saveInto: {
    local!gridSelection, //you create a variable to save grid selection data
    a!save(
    local!selectedId, //you save the selected value to another local variable
    reverse(local!gridSelection.selected)[1] //you reverse the local!gridSelection.selected to get the first value as the latest value
    ),
    a!save( // set the local value as null
    local!gridSelection.selected,
    null
    ),
    a!save( // reset the value to previous variable
    local!gridSelection.selected,
    local!selectedId
    )
    }
Children
  • 0
    Certified Senior Developer
    in reply to Shivam Gupta

    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're de-selecting a row. 

    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*/
        },
        /*...*/
    )