Editable Grid Pagination

Hi All

How To Write Pagination In Editable Grid ?Some Example

  Discussion posts and replies are publicly visible

Parents
  • Hi,

    You have to create the component of pagination and then adapt it to your case, here's an example that I used.

    load(
      local!data: {
        {
          id: 1,
          name: "John",
          value: "your value here!"
        },
        {
          id: 2,
          name: "Mary",
          value: "your value here!"
        },
        {
          id: 3,
          name: "Ben",
          value: "your value here!"
        },
        {
          id: 4,
          name: "Ryan",
          value: "your value here!"
        },
        {
          id: 5,
          name: "Amy",
          value: "your value here!"
        },
        {
          id: 6,
          name: "Jennifer",
          value: "your value here!"
        },
        {
          id: 7,
          name: "Joe",
          value: "your value here!"
        },
        {
          id: 8,
          name: "Melissa",
          value: "your value here!"
        },
        {
          id: 9,
          name: "Anthony",
          value: "your value here!"
        }
      },
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 3,
        sort: a!sortInfo(
          field: "id",
          ascending: true
        )
      ),
      with(
        local!datasubset: todatasubset(
          local!data,
          local!pagingInfo
        ),
        local!dataForCurrentPage: local!datasubset.data,
        {
          a!sectionLayout(
            contents: {
              a!boxLayout(
                label: "Sort",
                contents: {
                  a!columnsLayout(
                    columns: {
                      a!columnLayout(
                        contents: {
                          a!dropdownField(
                            label: "Field",
                            choiceLabels: {
                              "ID",
                              "Name",
                              "Value"
                            },
                            choiceValues: {
                              "id",
                              "name",
                              "value"
                            },
                            value: local!pagingInfo.sort.field,
                            saveInto: {
                              local!pagingInfo.sort.field,
                              a!save(
                                local!pagingInfo.startIndex,
                                1
                              )
                            }
                          )
                        }
                      ),
                      a!columnLayout(
                        contents: {
                          a!radioButtonField(
                            label: "Order",
                            choiceLabels: {
                              "Ascending",
                              "Descending"
                            },
                            choiceValues: {
                              true,
                              false
                            },
                            value: local!pagingInfo.sort.ascending,
                            saveInto: {
                              local!pagingInfo.sort.ascending,
                              a!save(
                                local!pagingInfo.startIndex,
                                1
                              )
                            },
                            choiceLayout: "COMPACT"
                          )
                        }
                      )
                    }
                  )
                }
              )
            }
          ),
          a!sectionLayout(
            contents: {
              a!forEach(
                items: local!dataForCurrentPage,
                expression: a!cardLayout(
                  contents: {
                    a!columnsLayout(
                      columns: {
                        a!columnLayout(
                          contents: {
                            a!textField(
                              label: "ID",
                              value: property(
                                fv!item,
                                "id"
                              ),
                              readOnly: true
                            )
                          },
                          width: "NARROW"
                        ),
                        a!columnLayout(
                          contents: {
                            a!textField(
                              label: "Name",
                              value: property(
                                fv!item,
                                "name"
                              ),
                              readOnly: true
                            )
                          }
                        ),
                        a!columnLayout(
                          contents: {
                            a!textField(
                              label: "Some value",
                              value: property(
                                fv!item,
                                "value"
                              ),
                              readOnly: true
                            )
                          }
                        )
                      }
                    )
                  },
                  style: "STANDARD"
                )
              )
    
            }
          ),
          a!sectionLayout(
            contents: {
              a!richTextDisplayField(
                value: {
                  a!richTextIcon(
                    icon: "chevron-left",
                    link: a!dynamicLink(
                      saveInto: a!save(
                        local!pagingInfo,
                        a!pagingInfo(
                          startIndex: local!pagingInfo.startIndex - local!pagingInfo.batchSize,
                          batchSize: local!pagingInfo.batchSize,
                          sort: local!pagingInfo.sort
                        )
                      ),
                      showWhen: local!pagingInfo.startIndex > 1
                    ),
                    linkStyle: "STANDALONE"
                  ),
                  a!richTextItem(
                    text: {
                      char(
                        32
                      ),
                      a!richTextItem(
                        text: {
                          joinarray(
                            {
                              property(
                                local!pagingInfo,
                                "startIndex"
                              ),
                              char(
                                45
                              ),
                              property(
                                local!pagingInfo,
                                "startIndex"
                              ) + property(
                                local!pagingInfo,
                                "batchSize"
                              ) - 1
                            },
                            char(
                              32
                            )
                          )
                        },
                        style: "STRONG"
                      ),
                      char(
                        32
                      ),
                      joinarray(
                        {
                          "of",
                          count(
                            local!data
                          )
                        },
                        char(
                          32
                        )
                      ),
                      char(
                        32
                      )
                    }
                  ),
                  a!richTextIcon(
                    icon: "chevron-right",
                    link: a!dynamicLink(
                      saveInto: a!save(
                        local!pagingInfo,
                        a!pagingInfo(
                          startIndex: local!pagingInfo.startIndex + local!pagingInfo.batchSize,
                          batchSize: local!pagingInfo.batchSize,
                          sort: local!pagingInfo.sort
                        )
                      ),
                      showWhen: local!pagingInfo.startIndex < count(
                        local!data
                      ) - local!pagingInfo.batchSize
                    ),
                    linkStyle: "STANDALONE"
                  )
                },
                align: "RIGHT"
              )
            }
          )
        }
      )
    )

Reply
  • Hi,

    You have to create the component of pagination and then adapt it to your case, here's an example that I used.

    load(
      local!data: {
        {
          id: 1,
          name: "John",
          value: "your value here!"
        },
        {
          id: 2,
          name: "Mary",
          value: "your value here!"
        },
        {
          id: 3,
          name: "Ben",
          value: "your value here!"
        },
        {
          id: 4,
          name: "Ryan",
          value: "your value here!"
        },
        {
          id: 5,
          name: "Amy",
          value: "your value here!"
        },
        {
          id: 6,
          name: "Jennifer",
          value: "your value here!"
        },
        {
          id: 7,
          name: "Joe",
          value: "your value here!"
        },
        {
          id: 8,
          name: "Melissa",
          value: "your value here!"
        },
        {
          id: 9,
          name: "Anthony",
          value: "your value here!"
        }
      },
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 3,
        sort: a!sortInfo(
          field: "id",
          ascending: true
        )
      ),
      with(
        local!datasubset: todatasubset(
          local!data,
          local!pagingInfo
        ),
        local!dataForCurrentPage: local!datasubset.data,
        {
          a!sectionLayout(
            contents: {
              a!boxLayout(
                label: "Sort",
                contents: {
                  a!columnsLayout(
                    columns: {
                      a!columnLayout(
                        contents: {
                          a!dropdownField(
                            label: "Field",
                            choiceLabels: {
                              "ID",
                              "Name",
                              "Value"
                            },
                            choiceValues: {
                              "id",
                              "name",
                              "value"
                            },
                            value: local!pagingInfo.sort.field,
                            saveInto: {
                              local!pagingInfo.sort.field,
                              a!save(
                                local!pagingInfo.startIndex,
                                1
                              )
                            }
                          )
                        }
                      ),
                      a!columnLayout(
                        contents: {
                          a!radioButtonField(
                            label: "Order",
                            choiceLabels: {
                              "Ascending",
                              "Descending"
                            },
                            choiceValues: {
                              true,
                              false
                            },
                            value: local!pagingInfo.sort.ascending,
                            saveInto: {
                              local!pagingInfo.sort.ascending,
                              a!save(
                                local!pagingInfo.startIndex,
                                1
                              )
                            },
                            choiceLayout: "COMPACT"
                          )
                        }
                      )
                    }
                  )
                }
              )
            }
          ),
          a!sectionLayout(
            contents: {
              a!forEach(
                items: local!dataForCurrentPage,
                expression: a!cardLayout(
                  contents: {
                    a!columnsLayout(
                      columns: {
                        a!columnLayout(
                          contents: {
                            a!textField(
                              label: "ID",
                              value: property(
                                fv!item,
                                "id"
                              ),
                              readOnly: true
                            )
                          },
                          width: "NARROW"
                        ),
                        a!columnLayout(
                          contents: {
                            a!textField(
                              label: "Name",
                              value: property(
                                fv!item,
                                "name"
                              ),
                              readOnly: true
                            )
                          }
                        ),
                        a!columnLayout(
                          contents: {
                            a!textField(
                              label: "Some value",
                              value: property(
                                fv!item,
                                "value"
                              ),
                              readOnly: true
                            )
                          }
                        )
                      }
                    )
                  },
                  style: "STANDARD"
                )
              )
    
            }
          ),
          a!sectionLayout(
            contents: {
              a!richTextDisplayField(
                value: {
                  a!richTextIcon(
                    icon: "chevron-left",
                    link: a!dynamicLink(
                      saveInto: a!save(
                        local!pagingInfo,
                        a!pagingInfo(
                          startIndex: local!pagingInfo.startIndex - local!pagingInfo.batchSize,
                          batchSize: local!pagingInfo.batchSize,
                          sort: local!pagingInfo.sort
                        )
                      ),
                      showWhen: local!pagingInfo.startIndex > 1
                    ),
                    linkStyle: "STANDALONE"
                  ),
                  a!richTextItem(
                    text: {
                      char(
                        32
                      ),
                      a!richTextItem(
                        text: {
                          joinarray(
                            {
                              property(
                                local!pagingInfo,
                                "startIndex"
                              ),
                              char(
                                45
                              ),
                              property(
                                local!pagingInfo,
                                "startIndex"
                              ) + property(
                                local!pagingInfo,
                                "batchSize"
                              ) - 1
                            },
                            char(
                              32
                            )
                          )
                        },
                        style: "STRONG"
                      ),
                      char(
                        32
                      ),
                      joinarray(
                        {
                          "of",
                          count(
                            local!data
                          )
                        },
                        char(
                          32
                        )
                      ),
                      char(
                        32
                      )
                    }
                  ),
                  a!richTextIcon(
                    icon: "chevron-right",
                    link: a!dynamicLink(
                      saveInto: a!save(
                        local!pagingInfo,
                        a!pagingInfo(
                          startIndex: local!pagingInfo.startIndex + local!pagingInfo.batchSize,
                          batchSize: local!pagingInfo.batchSize,
                          sort: local!pagingInfo.sort
                        )
                      ),
                      showWhen: local!pagingInfo.startIndex < count(
                        local!data
                      ) - local!pagingInfo.batchSize
                    ),
                    linkStyle: "STANDALONE"
                  )
                },
                align: "RIGHT"
              )
            }
          )
        }
      )
    )

Children