Skip to main content
Participating Frequently
Dec 5, 2024 4:37 AM UTC
Question

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?

12 replies

prasantap0900
Participating Frequently
Dec 5, 2024 5:18 AM UTC

Can you please elaborate more? 

yans8297Author
Participating Frequently
Dec 5, 2024 5:27 AM UTC

The user wants to display the column they want, for example, the current gridField displays the fields [ID, NAME, AGE, STATUS], but the user wants to display [ID, STATUS, AGE] through dropdown options or other ways.

jayaprakashr0001
Participating Frequently
Dec 5, 2024 5:33 AM UTC

1. For the specific fields what you want to show to the user have a show when condition for the gridfields .

yans8297Author
Participating Frequently
Dec 5, 2024 5:39 AM UTC

Yes, I can show the specific fields by the user's selected set and show when condition, but I don't have an idea of the order. because:
1. We can't dynamically adjust the order of the gridcolumn, right?
2. Our checkbox component can't save the values according to the order I choose, and it can't annotate the order, which makes it difficult for me to deal with the order.

jayaprakashr0001
Participating Frequently
Dec 5, 2024 5:50 AM UTC

Can you elaborate the use case

prasantap0900
Participating Frequently
Dec 5, 2024 6:33 AM UTC

I am giving you an example, you can develop like that.

a!localVariables(
  local!save : 2,
  {
  a!radioButtonField(
    label: "Is user ?",
    choiceLabels: {"User","Admin"},
    choiceValues: {1,2},
    value: local!save,
    saveInto: local!save,
    choiceStyle: "CARDS",
  ),
  a!gridField(
    label: "Read-only Grid",
    labelPosition: "ABOVE",
    data: 'recordType!{f55afdcb-53bf-4764-9d6b-79d1e1490735}PSB Details',
    columns: {
      a!gridColumn(
        label: "Id",
        sortField:  'recordType!{f55afdcb-53bf-4764-9d6b-79d1e1490735}PSB Details.fields.{c0258c07-713f-4c0f-8fed-f85fa4aaea65}id',
        value: fv!row[ 'recordType!{f55afdcb-53bf-4764-9d6b-79d1e1490735}PSB Details.fields.{c0258c07-713f-4c0f-8fed-f85fa4aaea65}id'],
        showWhen: local!save = 2
      ),
      a!gridColumn(
        label: "Name",
        sortField:  'recordType!{f55afdcb-53bf-4764-9d6b-79d1e1490735}PSB Details.fields.{a9d0f67a-cba2-4fda-bc8f-3dc112496562}firstName',
        value: fv!row[ 'recordType!{f55afdcb-53bf-4764-9d6b-79d1e1490735}PSB Details.fields.{a9d0f67a-cba2-4fda-bc8f-3dc112496562}firstName'],
        align: "START"
      ),
    }
  )
  }
)