Multiple Checkboxes in Editable Grid

Hi,

For my requirement, I'm using Editable Grid it contains multiple check boxes. I'm passing the local variable into the values. But for a single check box selection I am able to save the value, whereas if i'm trying to select multiple check boxes at a time, I am unable to save values. I want to check multiple values ​​and save all of them values.

 

  Discussion posts and replies are publicly visible

  • Hi ,
    Share your code snipped it would help us understand the issue.

    Regards,
    Sachin
  • 0
    A Score Level 1
    in reply to Sachin
    load(
    local!data: {},
    local!items: {
    {
    SiteName: "",
    SiteCountry: "",
    ManufacturingSteps: ""
    }
    },
    with(
    local!mfgsite: rule!CMP_qryMfgSitedetails(),
    local!mfgcountry: rule!CMP_qryCountryDetails(
    countryode: 1
    ),
    a!sectionLayout(
    label: "Supply Chain Details",
    isCollapsible: "True",
    isInitiallyCollapsed: "True",
    divider: "BELOW",
    contents: {
    a!gridLayout(
    label: "Site Information",
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "Site Name"
    ),
    a!gridLayoutHeaderCell(
    label: "Site Country"
    ),
    a!gridLayoutHeaderCell(
    label: "Manufacturing Steps"
    )
    },
    rows: {
    a!forEach(
    items: local!items,
    expression: a!gridRowLayout(
    contents: {
    a!dropdownField(
    label: "SiteName" & fv!index,
    choiceLabels: local!mfgsite.name,
    choiceValues: local!mfgsite.name,
    placeholderLabel: "--Select Site--",
    value: fv!item.SiteName,
    saveInto: fv!item.SiteName
    ),
    a!dropdownField(
    label: "SiteCountry" & fv!index,
    choiceLabels: local!mfgcountry.name,
    choiceValues: local!mfgcountry.name,
    placeholderLabel: "--Select Country--",
    value: fv!item.SiteCountry,
    saveInto: fv!item.SiteCountry
    ),
    a!checkboxField(
    label: "Manufacturing Steps" & fv!index,
    choiceLayout: "COMPACT",
    choiceLabels: cons!DFC_Sites,
    choiceValues: cons!DFC_Sites,
    value: fv!item.ManufacturingSteps,
    saveInto: {
    fv!item.ManufacturingSteps
    }
    )
    }
    )
    )
    },
    addRowLink: a!dynamicLink(
    label: "Add site",
    value: {
    SiteName: "",
    SiteCountry: "",
    ManufacturingSteps: {}
    },
    saveInto: a!save(
    local!items,
    append(
    local!items,
    save!value
    )
    )
    ),
    shadeAlternateRows: true
    ),
    a!textField(
    readOnly: true,
    value: local!items.ManufacturingSteps
    ),
    a!buttonLayout(
    primaryButtons: a!buttonWidgetSubmit(
    label: "Submit",
    style: "PRIMARY",
    confirmHeader: "Warning!",
    confirmMessage: "Steps will be added to the Database.
    Please Click Yes to Proceed",
    saveInto: a!writeToDataStoreEntity()
    )
    )
    }
    )
    )
    )
  • Hi,

    You can save multiple value in single type variable, here fv!item.ManufacturingSteps is single type variable.

    you can join the checkbox values with some special characters,

    Note: the data type should be TEXT

    try the below code.

     

     

    a!checkboxField(
    label: "Manufacturing Steps" & fv!index,
    choiceLayout: "COMPACT",
    choiceLabels: cons!DFC_Sites,
    choiceValues: cons!DFC_Sites,
    value:if(
           isnull(fv!item.ManufacturingSteps),
            null,
            touniformstring( split(fv!item.ManufacturingSteps,"#") )
          ),
    saveInto: {
    
      a!save(
        fv!item.ManufacturingSteps,
         if(
            isnull(save!value),
              null,
              joinarray(save!value,"#")
          )
    
        )
    
     }
    )

     

    Thanks

    Vinay

  • 0
    Certified Lead Developer

    Hi Narmada,

    See the following working code. Specifically note line 60: "value: tostring(fv!item.ManufacturingSteps),"

    When the fv!item.ManufacturingSteps is of Any Type, the checkbox will not remain checked. You will need to make sure your value field's type matches the checkBoxField's choiceValue type. 

    Let me know if that helps! If it doesn't - please provide similar values to your constants to ensure we can replicate your issue. 

     

    load(
      local!data: {},
      local!items: {
        {
          SiteName: "",
          SiteCountry: "",
          ManufacturingSteps: ""
        }
      },
      with(
        /*local!mfgsite: rule!CMP_qryMfgSitedetails(),*/
        /*local!mfgcountry: rule!CMP_qryCountryDetails(*/
          /*countryode: 1*/
        /*),*/
        a!sectionLayout(
          label: "Supply Chain Details",
          /*isCollapsible: "True",*/
          isInitiallyCollapsed: "True",
          divider: "BELOW",
          contents: {
            a!gridLayout(
              label: "Site Information",
              headerCells: {
                a!gridLayoutHeaderCell(
                  label: "Site Name"
                ),
                a!gridLayoutHeaderCell(
                  label: "Site Country"
                ),
                a!gridLayoutHeaderCell(
                  label: "Manufacturing Steps"
                )
              },
              rows: {
                a!forEach(
                  items: local!items,
                  expression: a!gridRowLayout(
                    contents: {
                      a!dropdownField(
                        label: "SiteName" & fv!index,
                        choiceLabels: {"MAN NAME1","MAN NAME2"},
                        choiceValues: {"MAN NAME1","MAN NAME2"},
                        placeholderLabel: "--Select Site--",
                        value: fv!item.SiteName,
                        saveInto: fv!item.SiteName
                      ),
                      a!dropdownField(
                        label: "SiteCountry" & fv!index,
                        choiceLabels: {"COUNTRY NAME1","COUNTRY NAME2"},
                        choiceValues: {"COUNTRY NAME1","COUNTRY NAME2"},
                        placeholderLabel: "--Select Country--",
                        value: fv!item.SiteCountry,
                        saveInto: fv!item.SiteCountry
                      ),
                      a!checkboxField(
                        label: "Manufacturing Steps" & fv!index,
                        choiceLayout: "COMPACT",
                        choiceLabels: {"Y"},
                        choiceValues: {"Y"},
                        value: tostring(fv!item.ManufacturingSteps),
                        saveInto: fv!item.ManufacturingSteps
                      )
                    }
                  )
                )
              },
              addRowLink: a!dynamicLink(
                label: "Add site",
                value: {
                  SiteName: "",
                  SiteCountry: "",
                  ManufacturingSteps: ""
                },
                saveInto: a!save(
                  local!items,
                  append(
                    local!items,
                    save!value
                  )
                )
              ),
              shadeAlternateRows: true
            ),
            a!textField(
              readOnly: true,
              /*value: local!items.ManufacturingSteps*/
              value: typename(typeof(local!items[1].ManufacturingSteps))
            ),
            a!buttonLayout(
              primaryButtons: a!buttonWidgetSubmit(
                label: "Submit",
                style: "PRIMARY",
                confirmHeader: "Warning!",
                confirmMessage: "Steps will be added to the Database.
    Please Click Yes to Proceed",
                saveInto: a!writeToDataStoreEntity()
              )
            )
          }
        )
      )
    )

  • Hi Narmada (narmadap) ,

    Your code looks fine the only thing is try creating cdt instead of local variable

    please find below screenshot which i have tested in my environment

    Note:

    Try to avoid calling queryentity in with function instead use it in saveInto of cascading components.