Sorting by date is not working on Read- only grid

Hello Everyone,

I am using below pagingInfo , gridcolumn , and pagingSaveInto in my interface where Approval Date is of datetime type

local!pagingInfo: a!pagingInfo(

startIndex:1,

batchSize: -1,

sort: a!sortInfo(field: "APPORVAL_DATE")

gridColumn(

label: "Approved On",

sortField: "APPORVAL_DATE",

value: fv!row.APPORVAL_DATE

)

pagingSaveInto: local!pagingInfo

 If approval date is between 7/1/2021 and 7/12/2021 then 

Expected result to be sorted by Date ie. 7/12, 7/11, 7/10, 7/9, 7/8, 7/7 and so on but sorting is not applied to the grid and resulting data is random sequence like 7/11 7/12 7/1 7/2 and so on.

Thank you for suggestions in advance.

  Discussion posts and replies are publicly visible

Parents Reply
  • Then I suspect the issue is in the datatype of that specific value. For example, in my sample code, I've just cast the DateTime value to a string. As a result, the sorting is not as expected.

    a!localVariables(
      local!data: a!forEach(
        items: enumerate(5) + 1,
        expression: {
          id: fv!item,
          APPORVAL_DATE: tostring(now() - fv!item)
        }
      ),
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: - 1,
        sort: a!sortInfo(field: "APPORVAL_DATE")
      ),
      {
        a!gridField(
          label: "Read-only Grid",
          labelPosition: "ABOVE",
          data: local!data,
          columns: {
            a!gridColumn(
              label: "Date",
              sortField: "APPORVAL_DATE",
              value: fv!row.APPORVAL_DATE
            )
          },
          initialSorts: a!sortInfo(field: "APPORVAL_DATE", ascending: true()),
          validations: {},
          pagingSaveInto: local!pagingInfo
        )
      }
    )

    Can you try casting the API result to a proper datatype?

Children