Refresh option in grid not working

Hi All,

Trying to refresh using a refresh variable in grid. Facing issue with refresh. Please find below code and let me know if any changes are required.

a!localVariables(
  local!refreshCounter: 0,
  local!startIndex: a!refreshVariable(
    value: 1,
    refreshOnVarChange: local!refreshCounter
  ),
  local!pagingInfo: a!pagingInfo(local!startIndex, 5),
  local!data: a!refreshVariable(
    value: rule!S_getAPI(),
    refreshOnVarChange: local!refreshCounter
  ),
  {
    a!buttonArrayLayout(
      a!buttonWidget(
        label: "Refresh",
        size: "SMALL",
        style: "SECONDARY",
        saveInto: {
          a!save(
            local!refreshCounter,
            local!refreshCounter + 1
          ),
          
        }
      )
    ),
    a!gridField(
      label: "Data",
      labelPosition: "ABOVE",
      data: local!data,
      columns: {
        a!gridColumn(
          label: "First Name",
          sortField: "firstName",
          value: fv!row.firstName
        ),
        a!gridColumn(
          label: "Last Name",
          sortField: "lastName",
          value: fv!row.lastName
        ),
        a!gridColumn(
          label: "Email",
          sortField: "email",
          value: fv!row.email
        ),
        a!gridColumn(
          label: "Phone",
          sortField: "phone",
          value: fv!row.phone
        )
      },
      validations: {},
      pagingSaveInto: a!save(
        local!startIndex,
        fv!pagingInfo.startIndex
      )
    )
  }
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Your code box worked fine, i'm unclear why you also pasted the code a second time below it - that just makes your original post harder to read.

    Your refreshCounter setup looks generally OK - that's how I'd configure it for a start.  I'm a little unclear what you're doing with your local!pagingInfo variable, as it doesn't seem to actually get used/referenced at all in your query.

    As far as the data query itself - what's happening inside rule!S_getAPI()?  If it's using its own local variables then you might need to push a reference to your refreshVariable into it as well.  Also, what are you expecting to see when you click "refresh"?  As in, are you sure the data queried will be different when you test it?  If it's still the same, for instance, you wouldn't see any change on the front end, until some update has happened in the source data, even if the refresh functionality is working fine.

Reply
  • 0
    Certified Lead Developer

    Your code box worked fine, i'm unclear why you also pasted the code a second time below it - that just makes your original post harder to read.

    Your refreshCounter setup looks generally OK - that's how I'd configure it for a start.  I'm a little unclear what you're doing with your local!pagingInfo variable, as it doesn't seem to actually get used/referenced at all in your query.

    As far as the data query itself - what's happening inside rule!S_getAPI()?  If it's using its own local variables then you might need to push a reference to your refreshVariable into it as well.  Also, what are you expecting to see when you click "refresh"?  As in, are you sure the data queried will be different when you test it?  If it's still the same, for instance, you wouldn't see any change on the front end, until some update has happened in the source data, even if the refresh functionality is working fine.

Children
No Data