How to implement custom fields to display in the gridField?

I want to implement a user-defined feature that allows specific fields to be displayed and the order to be adjusted.

For example, I currently have 5 columns(column 1-5) in readonly grid, and the user can present 3 of them as needed and can adjust the order, e.g. display [column 1, column 5, column 3].

Is there any way to implement this feature? Can you give me some advice?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Not for dropdown, for example, we have a grid like below:

    But there may be too many columns in this list, so users want to decide for themselves what columns to display and how to display them. for example, user want to display 3 columns and change the order, like below:

    I'm not sure if there's any way to implement this, my original idea was that the user would through dropdown to select the desired column, and we showed it by show when condition, but that doesn't solve the order problem, because neither dropdown nor checkbox has the ability to generate values in the order of selection.

  • Not for Dropdown. This is about the functionality of the gridField and gridColumn. For example, currently our list has the following fields.

    But the list here may have a lot of fields, so users want to decide what fields to display and how to display them depending on their needs. For example, user want 3 columns and change the order, like below:

  • 0
    Certified Senior Developer
    in reply to yans8297

    HI  ,

    Use the below code it will help 

    a!localVariables(
      local!data:{
        a!map(requestID:1,refNum:"LP012",subject:"Test1",asset:"Laptop"),
        a!map(requestID:2,refNum:"TB-2344",subject:"Test2",asset:"Tablet"),
      },
      local!gridFields1:{"Request Id","Reference Number","Subject","Asset"},
      local!selectedData,
      {
        a!multipleDropdownField(
          choiceLabels: local!gridFields1,
          choiceValues: local!gridFields1,
          label: "Column Types",
          placeholder: "--Select Columns--",
          value: local!selectedData,
          saveInto: local!selectedData
          
        ),
        a!gridField(
          label: "Read-only Grid",
          labelPosition: "ABOVE",
          data: local!data,
          columns: {
            a!gridColumn(
              label: "Request Id",
              value: fv!row.requestID,
              showWhen: if(
                a!isNotNullOrEmpty(local!selectedData),
                if(
                  contains(
                    touniformstring(local!selectedData),
                    touniformstring(local!gridFields1[1])
                  ),
                  true(),
                  false()
                ),
                true()
              )
    
    ,
              align: "END"
            ),
            a!gridColumn(
              label: "Reference Number",
              value: fv!row.refNum,
              showWhen: if(
                a!isNotNullOrEmpty(local!selectedData),
                if(
                  contains(
                    touniformstring(local!selectedData),
                    touniformstring(local!gridFields1[2])
                  ),
                  true(),
                  false()
                ),
                true()
              )
            ),
            a!gridColumn(
              label: "Subject",
              value:fv!row.subject,
              showWhen: if(
                a!isNotNullOrEmpty(local!selectedData),
                if(
                  contains(
                    touniformstring(local!selectedData),
                    touniformstring(local!gridFields1[3])
                  ),
                  true(),
                  false()
                ),
                true()
              )
            ),
            a!gridColumn(
              label: "Asset",
              value: fv!row.asset,
              align: "START",
              showWhen: if(
                a!isNotNullOrEmpty(local!selectedData),
                if(
                  contains(
                    touniformstring(local!selectedData),
                    touniformstring(local!gridFields1[4])
                  ),
                  true(),
                  false()
                ),
                true()
              )
            )
          },
          validations: {}
        )
        
      }
    )