Skip to main content
Known Participant
Mar 27, 2023 9:56 AM UTC
Question

Radio button in Grid

Hi Everyone,

Is there any way to include radio button instead of check box in read only grid for selection?

    12 replies

    harshitb6843
    Brainy
    Mar 27, 2023 10:10 AM UTC

    You can add it in a dedicated column and build custom logic around it so that when you select the radio button, it actually selects the grid row. 

    harshitb6843
    Brainy
    Mar 27, 2023 10:19 AM UTC

    But this is only possible in an editable grid. Not read-only grid. 
    You can use an editable one and make it look like read-only if required, but please remember that it will have slower performance than read-only. 

    harshitb6843
    Brainy
    Mar 27, 2023 10:27 AM UTC

    Somewhat like this. 

    a!localVariables(
      local!data: {
        { id: 1, name: "HarshitBumb.com" },
        { id: 2, name: "AppianSpace.com" },
        { id: 3, name: "chat.openai.com" }
      },
      local!selectedRow,
      {
        a!gridLayout(
          label: "Editable Grid",
          labelPosition: "ABOVE",
          headerCells: {
            a!gridLayoutHeaderCell(label: ""),
            a!gridLayoutHeaderCell(label: "Resources")
          },
          columnConfigs: {},
          rows: a!forEach(
            items: local!data,
            expression: a!gridRowLayout(
              id: fv!item.id,
              contents: {
                a!radioButtonField(
                  choiceLabels: "",
                  choiceValues: fv!item.id,
                  value: if(
                    tointeger(local!selectedRow) <> tointeger(fv!item.id),
                    null,
                    tointeger(local!selectedRow)
                  ),
                  saveInto: local!selectedRow
                ),
                a!richTextDisplayField(value: fv!item.name)
              }
            )
          ),
          selectionValue: local!selectedRow,
          selectionStyle: "ROW_HIGHLIGHT",
          selectable: true,
          selectionSaveInto: {},
          validations: {},
          shadeAlternateRows: true
        )
      }
    )