Combination of multi dropdown and editable grid

Certified Lead Developer

Hi guys,

I have the requirement where I need to have two components multi dropdown and an editable grid,

In the multiple drowndown component the user will select the value based on that the number of rows need to be populated in the grid. Where when the user deselect the value in dropdown the corresponding row in the grid need to deleted or not to shown to user.

  Discussion posts and replies are publicly visible

Parents
  • Hi santoshd378,

     

    PFA sample code. Hope this helps.

    load(
      local!multiSelectedValues,
      local!editableGridData: {
        {
          employeeId: 1,
          employeeName: "ABC"
        },
        {
          employeeId: 2,
          employeeName: "XYZ"
        },
        {
          employeeId: 3,
          employeeName: "PQR"
        }
      },
      local!filteredData,
      a!sectionLayout(
        contents: {
          a!multipleDropdownField(
            label: "Multi Select Dropdown",
            choiceLabels: index(
              local!editableGridData,
              "employeeName",
              {}
            ),
            choiceValues: index(
              local!editableGridData,
              "employeeId",
              {}
            ),
            value: local!multiSelectedValues,
            saveInto: {
              local!multiSelectedValues,
              a!save(
                local!filteredData,
                index(
                  local!editableGridData,
                  wherecontains(
                    local!multiSelectedValues,
                    index(
                      local!editableGridData,
                      "employeeId",
                      {}
                    )
                  ),
                  {}
                )
              )
            }
          ),
          a!gridLayout(
            label: "Editable Grid",
            headerCells: {
              a!gridLayoutHeaderCell(
                label: "Employee Id"
              ),
              a!gridLayoutHeaderCell(
                label: "Employee Name"
              )
            },
            rows: a!forEach(
              items: local!filteredData,
              expression: a!gridRowLayout(
                id: fv!index,
                contents: {
                  a!integerField(
                    readOnly: true(),
                    value: fv!item.employeeId,
                    saveInto: fv!item.employeeId
                  ),
                  a!textField(
                    value: fv!item.employeeName,
                    saveInto: fv!item.employeeName
                  )
                }
              )
            )
          )
        }
      )
    )

     

    Thank you,

    Arun

  • Hi Arun,

    i am trying something similar as shown in below screen. 

    Scenario: Populate data from Database as preselected values in multi drop down which is working fine as shown in below image. Now, need to save new value if user changes the selected values in multi drop down. Upon un-selecting any one value of preselected values, it is immediately unselecting both the preselected values and changes the Source object to empty array [] as you can see in another screen below. 

    Please advise on how to prepopulate multiple selected values and also be able save new values in the same rule input to update values in DB.

     

                                             

    Regards,

    Anusha

  • +1
    Certified Lead Developer
    in reply to anushas0002

    Hi anushas0002,

    Your MultipleDropDownField SaveInto looks like below

    saveInto: a!save(
    			ri!TechnologySelected.Source,
    			save!value
    		)

    save!value in the multiple dropdown holds the value of choiceValues which is actually local!sources.Id.

    I think you want to store both Source Id and DisplayName in the variable. If yes, you can try the below code

    saveInto: {
    			a!save(
    			  ri!TechnologySelected.Source,
    			  a!forEach(
    				items: save!value,
    				expression: {
    				  Id: fv!item,
    				  DisplayValue: displayvalue(
    					fv!item,
    					local!sources.Id,
    					local!sources.DisplayName,
    					null
    				  )
    				}
    			  )
    			)
    		}

  • Thank You Vimal. This fixed the issue and working as expected.
Reply Children
No Data