Skip to main content
shivas3219
Participating Frequently
Jan 21, 2025 8:08 AM UTC
Question

Editable grid

i have an editable grid and in single row i have checkbox and textfields, i need to make textfield readonly false based on selected option in checkbox in that particular row. Please let me know if any workaround available for this

    5 replies

    stefanhelzle0001
    Brainy
    Jan 21, 2025 8:15 AM UTC

    Please share some example code showing what you already have.

    davidj137213
    Brainy
    Jan 21, 2025 9:45 AM UTC
    nilanshum856600
    Participating Frequently
    Jan 21, 2025 10:04 AM UTC

    Please try this code and let me know if you need anything else.

    a!localVariables(
      local!data: { a!map(checkbox: null, text: null) },
      {
        a!gridLayout(
          label: "Editable Grid",
          labelPosition: "ABOVE",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Checkbox"),
            a!gridLayoutHeaderCell(label: "Text")
          },
          columnConfigs: {},
          rows: {
            a!forEach(
              items: local!data,
              expression: {
                a!gridRowLayout(
                  contents: {
                    a!checkboxField(
                      choiceLabels: "Make text editable",
                      choiceValues: true,
                      value: index(fv!item, "checkbox", null),
                      saveInto: fv!item.checkbox
                    ),
                    a!textField(
                      value: index(fv!item, "text", null),
                      saveInto: fv!item.text,
                      readOnly: not(or(index(fv!item, "checkbox", null)))
                    )
                  }
                )
              }
            )
          },
          addRowLink: a!dynamicLink(
            label: "Add new row",
            saveInto: a!save(
              local!data,
              append(
                local!data,
                a!map(checkbox: null, text: null)
              )
            )
          ),
          selectionSaveInto: {},
          validations: {},
          shadeAlternateRows: true
        )
      }
    )

    jayaprakashr0001
    Participating Frequently
    Jan 21, 2025 10:14 AM UTC

    HI [mention:7ea9d4bcad7b4583b5736bb99a152feb:e9ed411860ed4f2ba0265705b8793d05] 

    Please check this code. It might help you

    a!localVariables(
      local!options:{"Yes","No"},
      local!data:{
        a!map(check:"Yes",text:"sample text")
      },
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label:"Checkboxes"),
          a!gridLayoutHeaderCell(label:"Textfield"),
        },
        columnConfigs: {
          a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
          a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
        },
        rows: a!forEach(
          items: local!data,
          expression: a!gridRowLayout(
            contents: {
              a!checkboxField(
                choiceLabels: local!options,
                choiceValues: local!options,
                value: fv!item.check,
                saveInto: fv!item.check
              ),
              a!textField(
                value: fv!item.text,
                saveInto: fv!item.text,
                readOnly: if(
                  fv!item.check="Yes",
                  true(),
                  false()
                )
              )
            }
          )
        ),
        addRowLink: a!dynamicLink(
          label:"Add new row",
          saveInto: a!save(local!data,append(local!data,a!map(check:"",text:"")))
        )
      )
    )

    shivas3219
    Participating Frequently
    Jan 21, 2025 3:14 PM UTC

    Thank you all for the quick response. Got the resolution