Data only populates after clicking custom pagination arrow

Hello,

I am troubleshooting an issue I have with a GRID where there is no data populating the GRID when I load the page but after clicking one of the custom pagination arrows we have, the data populates but then we can't click the arrow to go to the next page of data. There are quite a few files involved in this screen but I suspect the issue has to do with paging?

On page load:

After clicking custom pagination arrow:

GRID code:

a!localVariables(
  local!pagingInfo,
  {
    rule!TB_SEC_customPaginationComponent(
      startIndex: ri!pagingInfo.startIndex,
      batchSize: cons!TB_INT_TRADE_BATCH_SIZE,
      totalCount: ri!totalCount,
      saveExpression: {
        a!save(
          local!pagingInfo,
          a!pagingInfo(
            startIndex: if(
              a!isNullOrEmpty(ri!pagingInfo.startIndex),
              0,
              ri!pagingInfo.startIndex
            ),
            batchSize: cons!TB_INT_TRADE_BATCH_SIZE,
            sort: ri!pagingInfo.sort
          )
        ),
        a!save(ri!pagingInfo, local!pagingInfo),
        a!save(
          ri!fcaReportDetails,
          todatasubset(
            rule!TB_RULE_castToFcaReportCdt(
              data: rule!TB_SP_executeSQlStatement(
                sqlStatement: rule!TB_RULE_generateSQLStatementForFcaReport(
                  podCode: ri!podCode,
                  orderId: ri!orderId,
                  vertInvestmentDesc: ri!vertInvestmentDesc,
                  tradeQuantity: ri!tradeQuantity,
                  execPrice: ri!execPrice,
                  ccy: ri!ccy,
                  principalAmount: ri!principalAmount,
                  usdRate: ri!usdRate,
                  gbpRate: ri!gbpRate,
                  usdValue: ri!usdValue,
                  bbTicker: ri!bbTicker,
                  vertAssetType: ri!vertAssetType,
                  vertTraderCode: ri!vertTraderCode,
                  vertExecSide: ri!vertExecSide,
                  pagingInfo: ri!pagingInfo
                )
              )
            )
          )
        )
      }
    ),
    a!gridLayout(
      label: "",
      labelPosition: "COLLAPSED",
      headerCells: {
        a!forEach(
          items: cons!TB_TXT_COLUMN_LIST_FOR_FCA_REPORT,
          expression: a!gridLayoutHeaderCell(label: fv!item, align: "CENTER")
        )
      },
      columnConfigs: {
        a!gridLayoutColumnConfig(width: "DISTRIBUTE")
      },
      rows: {
        a!forEach(
          items: ri!fcaReportDetails.data,
          expression: a!localVariables(
            local!rowData: fv!item,
            {
              a!gridRowLayout(
                id: fv!item.id,
                contents: {
                  a!forEach(
                    items: cons!TB_TXT_FIELDS_LIST_FOR_FCA_REPORT,
                    expression: a!textField(
                      readOnly: true(),
                      align: "CENTER",
                      label: {
                        cons!TB_TXT_COLUMN_LIST_FOR_FCA_REPORT[wherecontains(
                          fv!item, cons!TB_TXT_FIELDS_LIST_FOR_FCA_REPORT
                        )]
                      },
                      value: index(local!rowData, fv!item, null())
                    )
                  )
                },
                selectionDisabled: true()
              )
            }
          )
        )
      },
      shadeAlternateRows: true(),
      spacing: "DENSE"
    ),
    rule!TB_SEC_customPaginationComponent(
      startIndex: ri!pagingInfo.startIndex,
      batchSize: cons!TB_INT_TRADE_BATCH_SIZE,
      totalCount: ri!totalCount,
      saveExpression: {
        a!save(
          local!pagingInfo,
          a!pagingInfo(
            startIndex: if(
              a!isNullOrEmpty(ri!pagingInfo.startIndex),
              0,
              ri!pagingInfo.startIndex
            ),
            batchSize: cons!TB_INT_TRADE_BATCH_SIZE,
            sort: ri!pagingInfo.sort
          )
        ),
        a!save(ri!pagingInfo, local!pagingInfo),
        a!save(
          ri!fcaReportDetails,
          todatasubset(
            rule!TB_RULE_castToFcaReportCdt(
              data: rule!TB_SP_executeSQlStatement(
                sqlStatement: rule!TB_RULE_generateSQLStatementForFcaReport(
                  podCode: ri!podCode,
                  orderId: ri!orderId,
                  vertInvestmentDesc: ri!vertInvestmentDesc,
                  tradeQuantity: ri!tradeQuantity,
                  execPrice: ri!execPrice,
                  ccy: ri!ccy,
                  principalAmount: ri!principalAmount,
                  usdRate: ri!usdRate,
                  gbpRate: ri!gbpRate,
                  usdValue: ri!usdValue,
                  bbTicker: ri!bbTicker,
                  vertAssetType: ri!vertAssetType,
                  vertTraderCode: ri!vertTraderCode,
                  vertExecSide: ri!vertExecSide,
                  pagingInfo: ri!pagingInfo
                )
              )
            )
          )
        )
      }
    )
  }
)


Custom pagination code:
if(
  ri!batchSize > ri!totalCount,
  a!richTextDisplayField(
    align: "RIGHT",
    value: a!richTextItem(
      text: ri!totalCount & " items",
      style: "STRONG",
      size: "STANDARD"
    )
  ),
  {
    a!columnsLayout(
      columns: {
        a!columnLayout(contents: {}),
        a!columnLayout(contents: {}),
        a!columnLayout(
          contents: {
            a!sideBySideLayout(
              items: {
                a!sideBySideItem(
                  item: a!stampField(
                    labelPosition: "COLLAPSED",
                    icon: "angle-double-left-bold",
                    backgroundColor: if(ri!startIndex = 1, "SECONDARY", "ACCENT"),
                    link: if(
                      ri!startIndex = 1,
                      {},
                      a!dynamicLink(
                        saveInto: {
                          a!save(ri!startIndex, 1),
                          ri!saveExpression
                        }
                      )
                    ),
                    size: "TINY"
                  ),
                  width: "MINIMIZE"
                ),
                a!sideBySideItem(
                  item: a!stampField(
                    labelPosition: "COLLAPSED",
                    icon: "angle-left-bold",
                    backgroundColor: if(ri!startIndex = 1, "SECONDARY", "ACCENT"),
                    link: if(
                      ri!startIndex = 1,
                      {},
                      a!dynamicLink(
                        saveInto: {
                          a!save(
                            ri!startIndex,
                            ri!startIndex - ri!batchSize
                          ),
                          ri!saveExpression
                        }
                      )
                    ),
                    size: "TINY"
                  ),
                  width: "MINIMIZE"
                ),
                a!sideBySideItem(
                  item: a!richTextDisplayField(
                    align: "CENTER",
                    labelPosition: "COLLAPSED",
                    value: {
                      a!richTextItem(
                        text: " " & ri!startIndex & " - " & if(
                          ri!startIndex + ri!batchSize > ri!totalCount,
                          ri!totalCount,
                          ri!startIndex + ri!batchSize - 1
                        ) & " of " & ri!totalCount,
                        size: "MEDIUM",
                        style: "STRONG"
                      )
                    }
                  )
                ),
                a!sideBySideItem(
                  item: a!stampField(
                    labelPosition: "COLLAPSED",
                    icon: "angle-right-bold",
                    backgroundColor: if(
                      ri!startIndex + ri!batchSize > ri!totalCount,
                      "SECONDARY",
                      "ACCENT"
                    ),
                    link: if(
                      ri!startIndex + ri!batchSize > ri!totalCount,
                      {},
                      a!dynamicLink(
                        saveInto: {
                          a!save(
                            ri!startIndex,
                            ri!startIndex + ri!batchSize
                          ),
                          ri!saveExpression
                        }
                      )
                    ),
                    size: "TINY"
                  ),
                  width: "MINIMIZE"
                ),
                a!sideBySideItem(
                  item: a!stampField(
                    labelPosition: "COLLAPSED",
                    icon: "angle-double-right-bold",
                    backgroundColor: if(
                      ri!startIndex + ri!batchSize > ri!totalCount,
                      "SECONDARY",
                      "ACCENT"
                    ),
                    link: if(
                      ri!startIndex + ri!batchSize > ri!totalCount,
                      {},
                      a!dynamicLink(
                        saveInto: {
                          a!save(
                            ri!startIndex,
                            if(
                              mod(ri!totalCount, ri!batchSize) = 0,
                              ri!totalCount - ri!batchSize + 1,
                              ri!totalCount - mod(ri!totalCount, ri!batchSize) + 1
                            )
                          ),
                          ri!saveExpression
                        }
                      )
                    ),
                    size: "TINY"
                  ),
                  width: "MINIMIZE"
                ),
                
              },
              alignVertical: "MIDDLE",
              spacing: "SPARSE"
            )
          }
        )
      }
    )
  }
)

There is more code involved, but I suspect the issue is between these 2 files. We are getting the data from a stored procedure and I have confirmed that the SQL statement is properly retrieving the data. The reason I suspect the issue might be related to the pagination is because of the data populating after clicking the pagination arrow.

Any insight or help with this would be much appreciated. I can provide more code if discussion warrants it.

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    What are you passing in as the initial value of ri!fcaReportDetails?  If you're not initializing it to contain the first page of data, then a blank initial value would be the expected behavior IMHO.

  • Here is the code of the view that contains the GRID code you are referring to:

    a!localVariables(
      local!podCode: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!orderId: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!vertInvestmentDesc: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!tradeQuantity: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!execPrice: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!ccy: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!principalAmount: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!usdRate: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!gbpRate: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!usdValue: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!bbTicker: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!vertAssetType: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!vertTraderCode: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!vertExecSide: a!refreshVariable(
        value: null(),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!fcaReportDetails: a!refreshVariable(
        value: todatasubset(
          rule!TB_RULE_castToFcaReportCdt(
            data: rule!TB_SP_executeSQlStatement(
              sqlStatement: rule!TB_RULE_generateSQLStatementForFcaReport(
                podCode: local!podCode,
                orderId: local!orderId,
                vertInvestmentDesc: local!vertInvestmentDesc,
                tradeQuantity: local!tradeQuantity,
                execPrice: local!execPrice,
                ccy: local!ccy,
                principalAmount: local!principalAmount,
                usdRate: local!usdRate,
                gbpRate: local!gbpRate,
                usdValue: local!usdValue,
                bbTicker: local!bbTicker,
                vertAssetType: local!vertAssetType,
                vertTraderCode: local!vertTraderCode,
                vertExecSide: local!vertExecSide,
                pagingInfo: ri!pagingInfo,
                getTotalCount: true()
              )
            )
          )
        ),
        refreshOnVarChange: { ri!refreshValue }
      ),
      local!totalCount: a!refreshVariable(
        value: index(
          rule!TB_SP_executeSQlStatement(
            sqlStatement: rule!TB_RULE_generateSQLStatementForFcaReport(
              podCode: local!podCode,
              orderId: local!orderId,
              vertInvestmentDesc: local!vertInvestmentDesc,
              tradeQuantity: local!tradeQuantity,
              execPrice: local!execPrice,
              ccy: local!ccy,
              principalAmount: local!principalAmount,
              usdRate: local!usdRate,
              gbpRate: local!gbpRate,
              usdValue: local!usdValue,
              bbTicker: local!bbTicker,
              vertAssetType: local!vertAssetType,
              vertTraderCode: local!vertTraderCode,
              vertExecSide: local!vertExecSide,
              pagingInfo: ri!pagingInfo,
              getTotalCount: true()
            )
          ),
          "TOTALCOUNT",
          null()
        ),
        refreshOnVarChange: { ri!refreshValue }
      ),
      {
        rule!TB_SEC_fcaReportFilters(
          pagingInfo: ri!pagingInfo,
          totalCount: local!totalCount,
          podCode: local!podCode,
          vertInvestmentDesc: local!vertInvestmentDesc,
          fcaReportDetails: local!fcaReportDetails,
          tradeQuantity: local!tradeQuantity,
          execPrice: local!execPrice,
          ccy: local!ccy,
          usdRate: local!usdRate,
          gbpRate: local!gbpRate,
          usdValue: local!usdValue,
          bbTicker: local!bbTicker,
          vertAssetType: local!vertAssetType,
          vertTraderCode: local!vertTraderCode,
          vertExecSide: local!vertExecSide,
          orderId: local!orderId,
          principalAmount: local!principalAmount
        ),
        a!cardLayout(
          contents: {
            rule!TB_SEC_fcaReportAdditionalAction(
              totalCount: local!totalCount,
              podCode: local!podCode,
              orderId: local!orderId,
              vertInvestmentDesc: local!vertInvestmentDesc,
              tradeQuantity: local!tradeQuantity,
              execPrice: local!execPrice,
              ccy: local!ccy,
              principalAmount: local!principalAmount,
              usdRate: local!usdRate,
              gbpRate: local!gbpRate,
              usdValue: local!usdValue,
              bbTicker: local!bbTicker,
              vertAssetType: local!vertAssetType,
              vertTraderCode: local!vertTraderCode,
              vertExecSide: local!vertExecSide
            ),
            rule!TB_GRID_fcaReportView(
              fcaReportDetails: local!fcaReportDetails,
              podCode: local!podCode,
              vertInvestmentDesc: local!vertInvestmentDesc,
              tradeQuantity: local!tradeQuantity,
              execPrice: local!execPrice,
              ccy: local!ccy,
              usdRate: local!usdRate,
              gbpRate: local!gbpRate,
              usdValue: local!usdValue,
              bbTicker: local!bbTicker,
              vertAssetType: local!vertAssetType,
              vertTraderCode: local!vertTraderCode,
              vertExecSide: local!vertExecSide,
              orderId: local!orderId,
              principalAmount: local!principalAmount,
              totalCount: local!totalCount,
              recordLock: ri!recordLock,
              lockingDetails: ri!lockingDetails
            )
          },
          marginAbove: "STANDARD"
        )
      }
    )

    You can see in this code that fcaReportDetails get initialized as a local variable:

    local!fcaReportDetails: a!refreshVariable(
        value: todatasubset(
          rule!TB_RULE_castToFcaReportCdt(
            data: rule!TB_SP_executeSQlStatement(
              sqlStatement: rule!TB_RULE_generateSQLStatementForFcaReport(
                podCode: local!podCode,
                orderId: local!orderId,
                vertInvestmentDesc: local!vertInvestmentDesc,
                tradeQuantity: local!tradeQuantity,
                execPrice: local!execPrice,
                ccy: local!ccy,
                principalAmount: local!principalAmount,
                usdRate: local!usdRate,
                gbpRate: local!gbpRate,
                usdValue: local!usdValue,
                bbTicker: local!bbTicker,
                vertAssetType: local!vertAssetType,
                vertTraderCode: local!vertTraderCode,
                vertExecSide: local!vertExecSide,
                pagingInfo: ri!pagingInfo,
                getTotalCount: true()
              )
            )
          )
        ),
        refreshOnVarChange: { ri!refreshValue }
      ),


    And then towards the bottom when TB_GRID_fcaReportView gets called the rule input fcaReportDetails gets set to the local variable we initialized above:
    rule!TB_GRID_fcaReportView(
              fcaReportDetails: local!fcaReportDetails,
              podCode: local!podCode,
              vertInvestmentDesc: local!vertInvestmentDesc,
              tradeQuantity: local!tradeQuantity,
              execPrice: local!execPrice,
              ccy: local!ccy,
              usdRate: local!usdRate,
              gbpRate: local!gbpRate,
              usdValue: local!usdValue,
              bbTicker: local!bbTicker,
              vertAssetType: local!vertAssetType,
              vertTraderCode: local!vertTraderCode,
              vertExecSide: local!vertExecSide,
              orderId: local!orderId,
              principalAmount: local!principalAmount,
              totalCount: local!totalCount,
              recordLock: ri!recordLock,
              lockingDetails: ri!lockingDetails
            )

  • 0
    Certified Lead Developer
    in reply to thomasewood95
    fcaReportDetails get initialized as a local variable

    That looks OK (no comment about undue convolutedness though... *headache.gif*), but how sure are you that it's actually getting initialized (at that level) with an actually correct data value?

  • I'm not so sure.. because the weird part is that when I load into the view.. you can see on the right side of this screenshot that the data for fcaReportDetails is all null. And then if I click on the custom pagination arrows we have after clicking one of the arrows data appears and you can see on the right side of the 2nd screenshot that data is now in there after clicking a custom pagination arrow?

    No data on loading in to the view:

    data after clicking on the custom pagination arrows above the GRID:

    As you can see here, I know that the data is able to be retrieved because of this.. but unsure why there is no data on the initial load in.. it also seems that it shows 1 page of 30 items of data and I can't go to the next page using the arrows after that first click. This is what made me think it was something in the custom pagination code I share in the original post.

    Trust me I understand how much of a headache all of this may look.. I am the only developer on this project after other developers were on it for about 1 year, so most of it was not created by me but rather maintained and updated/improved.

  • 0
    Certified Lead Developer
    in reply to thomasewood95
    developers were on it for about 1 year

    been there.

    IMHO you need to really drill down on that initial query.  What's your initial value for ri!pagingInfo?  The initial query seems to be referring to an RI value and not a locally declared one.

    Going forward I'd also suggest that your custom paging info controls don't really need to re-call the entire query for each page load, if the whole thing is structured properly - you should be able to have it save an updated paging value and use variable chaining to have that refresh the top-level value.  But since that messes with your current setup (and isn't your current problem) i'd suggest solving your current problem first.

Reply
  • 0
    Certified Lead Developer
    in reply to thomasewood95
    developers were on it for about 1 year

    been there.

    IMHO you need to really drill down on that initial query.  What's your initial value for ri!pagingInfo?  The initial query seems to be referring to an RI value and not a locally declared one.

    Going forward I'd also suggest that your custom paging info controls don't really need to re-call the entire query for each page load, if the whole thing is structured properly - you should be able to have it save an updated paging value and use variable chaining to have that refresh the top-level value.  But since that messes with your current setup (and isn't your current problem) i'd suggest solving your current problem first.

Children
No Data