Sort read only fields of an editable grid

Hi,

I have an editable grid with 5 read only fields and one editable fields . I need to sort the readonly fields . I use 

 a!gridLayout(

)

Can i add the pagingInfo inside the "with" ? 

is it possible to have a sortable editable grid ?

  Discussion posts and replies are publicly visible

Parents
  • Its possible, just not pretty

     

    load(
      local!data: {
        {
          id: 1,
          firstName: "Steve",
          lastName: "Jobs"
        },
        {
          id: 2,
          firstName: "Lebron",
          lastName: "James"
        },
        {
          id: 3,
          firstName: "Mark",
          lastName: "Zuckerberg"
        }
      },
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: - 1,
        sort: a!sortInfo(
          field: "id",
          ascending: true
        )
      ),
      with(
        local!sortedData: todatasubset(
          arrayToPage: local!data,
          pagingConfiguration: local!pagingInfo
        ),
        {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!dropdownField(
                    label: "field",
                    choiceLabels: {
                      "ID",
                      "FIRST NAME",
                      "LAST NAME"
                    },
                    choiceValues: {
                      "id",
                      "firstName",
                      "lastName"
                    },
                    value: local!pagingInfo.sort.field,
                    saveInto: local!pagingInfo.sort.field
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!dropdownField(
                    label: "ascending",
                    choiceLabels: {
                      "TRUE",
                      "FALSE"
                    },
                    choiceValues: {
                      true,
                      false
                    },
                    value: local!pagingInfo.sort.ascending,
                    saveInto: local!pagingInfo.sort.ascending
                  )
                }
              )
            }
          ),
          a!gridLayout(
            headerCells: {
              a!gridLayoutHeaderCell(
                label: "ID"
              ),
              a!gridLayoutHeaderCell(
                label: "Name"
              ),
              a!gridLayoutHeaderCell()
            },
            columnConfigs: {
              a!gridLayoutColumnConfig(
                width: "ICON"
              ),
              a!gridLayoutColumnConfig(),
              a!gridLayoutColumnConfig(
                width: "ICON"
              )
            },
            rows: a!forEach(
              items: local!sortedData,
              expression: a!gridRowLayout(
                id: fv!index,
                contents: {
                  a!integerField(
                    value: fv!item.id,
                    readOnly: true
                  ),
                  a!textField(
                    value: concat(
                      fv!item.firstName & " " & fv!item.lastName
                    ),
                    saveInto: {
                      a!save(
                        fv!item.firstName,
                        index(
                          split(
                            save!value,
                            " "
                          ),
                          1,
                          ""
                        )
                      ),
                      a!save(
                        fv!item.lastName,
                        index(
                          split(
                            save!value,
                            " "
                          ),
                          2,
                          ""
                        )
                      )
                    }
                  ),
                  a!imageField(
                    images: a!documentImage(
                      document: a!iconIndicator(
                        icon: "REMOVE"
                      ),
                      link: a!dynamicLink(
                        value: wherecontains(
                          fv!item,
                          local!data
                        ),
                        saveInto: a!save(
                          local!data,
                          remove(
                            local!data,
                            save!value
                          )
                        )
                      )
                    ),
                    size: "ICON",
                    align: "CENTER"
                  )
                }
              )
            ),
            addRowLink: a!dynamicLink(
              label: "Add",
              value: {
                id: count(
                  local!data
                ) + 1
              },
              saveInto: a!save(
                local!data,
                append(
                  local!data,
                  save!value
                )
              )
            )
          )
        }
      )
    )

Reply
  • Its possible, just not pretty

     

    load(
      local!data: {
        {
          id: 1,
          firstName: "Steve",
          lastName: "Jobs"
        },
        {
          id: 2,
          firstName: "Lebron",
          lastName: "James"
        },
        {
          id: 3,
          firstName: "Mark",
          lastName: "Zuckerberg"
        }
      },
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: - 1,
        sort: a!sortInfo(
          field: "id",
          ascending: true
        )
      ),
      with(
        local!sortedData: todatasubset(
          arrayToPage: local!data,
          pagingConfiguration: local!pagingInfo
        ),
        {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!dropdownField(
                    label: "field",
                    choiceLabels: {
                      "ID",
                      "FIRST NAME",
                      "LAST NAME"
                    },
                    choiceValues: {
                      "id",
                      "firstName",
                      "lastName"
                    },
                    value: local!pagingInfo.sort.field,
                    saveInto: local!pagingInfo.sort.field
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!dropdownField(
                    label: "ascending",
                    choiceLabels: {
                      "TRUE",
                      "FALSE"
                    },
                    choiceValues: {
                      true,
                      false
                    },
                    value: local!pagingInfo.sort.ascending,
                    saveInto: local!pagingInfo.sort.ascending
                  )
                }
              )
            }
          ),
          a!gridLayout(
            headerCells: {
              a!gridLayoutHeaderCell(
                label: "ID"
              ),
              a!gridLayoutHeaderCell(
                label: "Name"
              ),
              a!gridLayoutHeaderCell()
            },
            columnConfigs: {
              a!gridLayoutColumnConfig(
                width: "ICON"
              ),
              a!gridLayoutColumnConfig(),
              a!gridLayoutColumnConfig(
                width: "ICON"
              )
            },
            rows: a!forEach(
              items: local!sortedData,
              expression: a!gridRowLayout(
                id: fv!index,
                contents: {
                  a!integerField(
                    value: fv!item.id,
                    readOnly: true
                  ),
                  a!textField(
                    value: concat(
                      fv!item.firstName & " " & fv!item.lastName
                    ),
                    saveInto: {
                      a!save(
                        fv!item.firstName,
                        index(
                          split(
                            save!value,
                            " "
                          ),
                          1,
                          ""
                        )
                      ),
                      a!save(
                        fv!item.lastName,
                        index(
                          split(
                            save!value,
                            " "
                          ),
                          2,
                          ""
                        )
                      )
                    }
                  ),
                  a!imageField(
                    images: a!documentImage(
                      document: a!iconIndicator(
                        icon: "REMOVE"
                      ),
                      link: a!dynamicLink(
                        value: wherecontains(
                          fv!item,
                          local!data
                        ),
                        saveInto: a!save(
                          local!data,
                          remove(
                            local!data,
                            save!value
                          )
                        )
                      )
                    ),
                    size: "ICON",
                    align: "CENTER"
                  )
                }
              )
            ),
            addRowLink: a!dynamicLink(
              label: "Add",
              value: {
                id: count(
                  local!data
                ) + 1
              },
              saveInto: a!save(
                local!data,
                append(
                  local!data,
                  save!value
                )
              )
            )
          )
        }
      )
    )

Children
No Data