Paging in the grid creates the problem

Hi Everyone ,

When try to keep the batchSize in the paging info , it display that the totalnumber has been exceeded by largest column data 


My table looks like 

Type Description Country
Nameabc1 abc

Brasil , India

nameabc2 def

Nepal

nameabc3 das

Australia,USA


load(
  local!defaultPagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: - 1,
    sort: {
      /* Default to sort in reverse chronological order */
      a!sortInfo(
        field: "Type",
        ascending: false
      )
    }
  ),
  local!pagingInfo: local!defaultPagingInfo,
  with(
    local!datasubset: todatasubset(
    a!foreach(items : rule!TAS_generateDataSubset(ID: ri!IDnum),
            expression : fv!item.data),
    local!pagingInfo),
    {
       a!gridField(
        label: "Deal Collateral",
        labelPosition: "COLLAPSED",
        totalCount: local!datasubset.totalCount,
        emptyGridMessage: resource(
          "No Collateral available"
        ),
        columns : {
            a!gridTextColumn(
            label: resource("Type"),
            field: "Type",
            data: a!forEach(
              items: local!datasubset,
              expression: a!forEach(
                items: fv!item.data,
                expression: a!forEach(
                  items: fv!item,
                  expression: index(
                    index(
                      fv!item,
                      "Type",
                      null
                    ),
                    "name",
                    null
                  )
                )
              )
            )
          ),
          a!gridTextColumn(
            label: resource(
              "Description"
            ),
            field: "description",
            data: a!forEach(
              items: local!datasubset,
              expression: a!forEach(
                items: fv!item.data,
                expression: a!forEach(
                  items: fv!item,
                  expression: index(
                    fv!item,
                    "description",
                    null
                  )
                )
              )
            )
          )
          )
    },
     value: local!pagingInfo,
        saveInto: {
          local!pagingInfo
        },
    )
    )

2.  a!foreach(

items : rule!TAS_generateDataSubset(ID: ri!IDnum),
expression : fv!item.data)

Returns ==> [Type=[id=1, name=nameabc1], country=[id=Bra, name=Brasil]; [id=Ind, name=India], description=abc];[Type=[id=2, name=nameabc2], country=[id=Nep, name=Nepal], description=Testing def]


Can anyone help me in paging the correct way . 

  Discussion posts and replies are publicly visible

  • I think the issue is with the country column, since that contains a list of lists. I'd suggest updating your expression to cast the full list of countries for the given row to a single string like this:

    a!gridTextColumn(
      label: resource("Country"),
      field: "country",
      data: a!forEach(
        items: local!datasubset,
        expression: tostring(
          index(
            fv!item,
            "country",
            ""
          )
        )
      )
    )

    It's actually decently rare to need many nested a!forEach() functions, so usually there is a simpler solution rather than having to nest all of those together so many times!

  • 0
    Certified Lead Developer

    Peter Lewis is stating basically exactly what I was about to say.

    I'll just add that you may be able to get by with a simple joinArray() function, which you will want to do with a convenient separator to make sure your list converted to a string still looks like a list of items to your end users.  You can add spaces in your separator as well, so you can make the formatting real nice.

    Whichever method is easiest.   There's no wrong answers among the things that make the pink box stop.

  • Good point, the tostring() I have in my example above would always concatenate with semicolons, so joinarray() might be better if you want to separate with a comma or something else.