Skip to main content
New Participant
February 2, 2022
Question

disabled radio buton

  • February 2, 2022
  • 9 replies
  • 3 views

ihave one radio button in editable grid so when i select one option it should be disabled how can i do it

    9 replies

    stefanhelzle0001
    Brainy
    February 2, 2022

    You want to disable the whole radio button component when a specific item is selected?

    Interesting requirement. Can you elaborate? What did you try? Code snippet?

    peter.lewis
    Employee
    February 2, 2022

    Yeah I think we need a lot more informaiton. Disabling the radio button when selecting an option frankly seems like a frustrating experience for the user to me. What if they select the option by accident? Now they can't change it back to something else? 

    agamb0001
    Participating Frequently
    February 2, 2022

    Hi [mention:02483f443bc54e838b45a6af7f3dacaa:e9ed411860ed4f2ba0265705b8793d05],

    You could use the disable property of a component to disable it and code it according to your selected value.

    Here's a eg code snippet. It disables a text field when the radio button has a specific value (3 here)

    You can use the local disableSelection variable to disable the radiobutton too / any other components similarly

    a!gridLayout(
      headerCells: {
        a!gridLayoutHeaderCell(label: "Radio Button"),
        a!gridLayoutHeaderCell(label: "Data")
      },
      rows: a!gridRowLayout(
        contents: {
          a!localVariables(
            local!radioButton: null,
            local!disableSelection: false(),
            local!textbox,
            {
              a!radioButtonField(
                choiceLabels: { "One", "Two", "Three" },
                choiceValues: { 1, 2, 3 },
                value: local!radioButton,
                saveInto: {
                  local!radioButton,
                  /*Disable selection of Text field when value is 3*/
                  a!save(local!disableSelection, save!value = 3)
                }
              ),
              a!textField(
                value: local!textbox,
                saveInto: local!textbox,
                disabled: local!disableSelection
              )
            }
          )
        }
      )
    )

    stewart.burchell
    Employee
    February 2, 2022

    Typically you disable input controls based upon the values selected in other input controls e.g., you have a radio button where you can select "Yes" or "No" and if you select, say, "No" then a logically related input text field is then disabled (although I'd recommend showing/hiding rather than disabling)

    Known Participant
    March 21, 2022

    A tack on question here, is there a way to disable a single option for a radio button field?

    stefanhelzle0001
    Brainy
    March 21, 2022

    Individual options cannot be disabled.