Read Only Grid - Setting Page Number

Certified Associate Developer

I have a record-backed read only grid with multiple pages (10 rows per page). In the interface the user selects 1 row in the grid, the grid is hidden and input fields are shown, and when the user hits a button the fields are hidden and the grid is refreshed (to show changes made in fields) and shown to the user again. The problem I am having is the page that the user is on gets reset when the grid is reloaded, so if they selected something on page 10, they would be back on page 1 after the grid refreshes and would need to navigate back to page 10.

Is there anyway to keep and/or save and reapply the current page number to the grid so that the user does not have to find their place again?

I know there is the "pagingSaveInto" parameter that saves the current paging info of the grid, but I don't see a way to apply that to the grid.

I have attached the SAIL code for my gridField component below.

Any advice or direction is greatly appreciated!

a!gridField(
    label: "Recommendation Grid",
    labelPosition: "COLLAPSED",
    data: a!recordData(
      recordType: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp',
      filters: a!queryLogicalExpression(
        operator: "AND",
        filters: {
          a!queryFilter(
            field: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{d0c49889-6f08-4eba-bc9f-d04cadb88d17}custId',
            operator: "=",
            value: ri!custID
          ),
          a!queryFilter(
            field: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{69bb655b-6792-4d0c-882d-e808d9162b7d}locId',
            operator: "=",
            value: ri!locID
          )
        },
        ignoreFiltersWithEmptyValues: true
      )
    ),
    columns: {
      a!gridColumn(
        label: "Equipment Id",
        sortField: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{351098f2-3bd8-40ca-9d8f-2ce3c5162466}equipId',
        value: fv!row['recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{351098f2-3bd8-40ca-9d8f-2ce3c5162466}equipId']
      ),
      a!gridColumn(
        label: "Service Description",
        sortField: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.relationships.{ffc37494-c395-4c92-abf4-ee496a2ea7fb}samsSurveyData.fields.{5898e6c1-9b33-4563-a3f8-5e8b77733da3}serviceDescription',
        value: fv!row['recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.relationships.{ffc37494-c395-4c92-abf4-ee496a2ea7fb}samsSurveyData.fields.{5898e6c1-9b33-4563-a3f8-5e8b77733da3}serviceDescription']
      ),
      a!gridColumn(
        label: "Recommended Part Number",
        sortField: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{25c9c265-5e3b-4b03-8f40-9e09e788b815}adviceid',
        value: fv!row['recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{25c9c265-5e3b-4b03-8f40-9e09e788b815}adviceid']
      ),
      a!gridColumn(
        label: "Recommended Flush Plan",
        sortField: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{43147ee1-1b62-4046-bf12-31195409a794}recFlushPlan',
        value: fv!row['recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{43147ee1-1b62-4046-bf12-31195409a794}recFlushPlan']
      ),
      a!gridColumn(
        label: "Comments",
        sortField: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{8aed024e-4792-4f66-9cac-799c04f5838e}recComments',
        value: fv!row['recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{8aed024e-4792-4f66-9cac-799c04f5838e}recComments']
      )
    },
    initialSorts: a!sortInfo(
      field: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{351098f2-3bd8-40ca-9d8f-2ce3c5162466}equipId',
      ascending: true()
    ),
    selectable: true(),
    selectionStyle: "ROW_HIGHLIGHT",
    selectionValue: local!selectionValue,
    selectionSaveInto: {
      local!selectionValue,
      a!save(
        local!editRow,
        fv!selectedRows['recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{351098f2-3bd8-40ca-9d8f-2ce3c5162466}equipId'][1]
      ),
      a!save(
        ri!recInfo,
        a!queryRecordByIdentifier(
          recordType: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp',
          identifier: local!selectionValue[1]
        )
      )
    },
    maxSelections: 1,
    validations: {},
    borderStyle: "LIGHT",
    refreshOnVarChange: local!gridUpdate,
    refreshAfter: "RECORD_ACTION",
    userFilters: {
      'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.filters.{3163b259-e8f7-4c1c-87be-c3dd00a7bfbf}recTemp_RecStatusFilter'
    },
    showSearchBox: true,
    showRefreshButton: true,
    pageSize: 10,
    pagingSaveInto: {
      a!save(
        local!gridPagingInfo,
        fv!pagingInfo
      )
    }
  )

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi, ideally this should work without any additional configuration. I have tried with the simple grid and added the show-when logics on the grid selection and button 'save into' parameter. Please refer to the below code:

    {
      a!sectionLayout(
        label: "Section",
        contents: {
          a!textField(label: "Test", showWhen: ri!showTextField),
          a!buttonArrayLayout(
            showWhen: ri!showTextField,
            buttons: {
              a!buttonWidget(
                label: "Button",
                style: "OUTLINE",
                saveInto: { a!save(ri!showTextField, false()) }
              )
            },
            align: "START",
            marginBelow: "NONE"
          ),
          a!gridField(
            label: "Read-only Grid",
            labelPosition: "ABOVE",
            data: 'recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case',
            columns: {
              a!gridColumn(
                label: "Name",
                sortField: 'recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{2aaca276-76e1-4f0c-8fd2-d45dceb89a41}name',
                value: a!richTextDisplayField(
                  value: {
                    a!richTextItem(
                      text: {
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{2aaca276-76e1-4f0c-8fd2-d45dceb89a41}name']
                      },
                      link: a!recordLink(
                        recordType: 'recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case',
                        identifier: fv!identifier
                      ),
                      linkStyle: "STANDALONE",
                      size: "MEDIUM"
                    ),
                    char(10),
                    a!richTextItem(
                      text: {
                        a!richTextItem(
                          text: {
                            a!richTextIcon(
                              icon: fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{11709256-3edf-4d81-9e94-e1f0f84b2fdc}nzcCaseType.fields.{eb9aab61-9ad4-4084-a500-f1ef8c3169a2}icon']
                            ),
                            " "
                          }
                        ),
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{11709256-3edf-4d81-9e94-e1f0f84b2fdc}nzcCaseType.fields.{9148c2dc-76f0-4c1d-a31c-d1fb3e656c81}label'],
                        if(a!isPageWidth("PHONE"), char(10), " | "),
                        a!richTextIcon(icon: "calendar"),
                        " ",
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{b5774e8b-a9d0-45c2-85c0-10fec364c27f}createdOn']
                      },
                      color: "SECONDARY"
                    )
                  }
                ),
                width: if(a!isPageWidth("PHONE"), "MEDIUM", "AUTO")
              ),
              a!gridColumn(
                label: "Priority",
                sortField: 'recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{681e9c6e-ae24-411e-953b-85e532fb564a}id',
                value: a!richTextDisplayField(
                  value: {
                    a!richTextIcon(
                      icon: fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{60932b18-0069-495f-9562-2a4b416865af}nzcCasePriority.fields.{daf18ff8-63c9-41c5-85a2-5409e8c9a9f4}icon'],
                      caption: fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{60932b18-0069-495f-9562-2a4b416865af}nzcCasePriority.fields.{2409d34c-7f91-4286-a450-fdf93e03a82d}label'],
                      color: fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{60932b18-0069-495f-9562-2a4b416865af}nzcCasePriority.fields.{ff03cf25-d27d-4323-8975-c621075bab2c}color'],
                      size: "LARGE"
                    )
                  }
                ),
                align: "CENTER",
                width: if(
                  a!isPageWidth("PHONE"),
                  "NARROW",
                  "NARROW_PLUS"
                )
              ),
              a!gridColumn(
                label: "Status",
                sortField: 'recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{c352c6b4-4199-4eb5-b473-0b268648cb10}statusId',
                value: a!richTextDisplayField(
                  value: {
                    a!richTextIcon(
                      icon: fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{59de7399-85e5-4db2-ae13-1590f2955b36}nzcCaseStatus.fields.{199a0b1c-e902-490d-802d-549f85be0e5e}icon'],
                      caption: if(
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{c352c6b4-4199-4eb5-b473-0b268648cb10}statusId'] = cons!NZC_TASK_GROUP_STATUS_ID,
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{d644a43d-f482-4b9b-99fb-a9052050e902}nzcTaskGroup.fields.{922c5189-6e56-4af0-896e-ee1319da2ff0}name'],
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{59de7399-85e5-4db2-ae13-1590f2955b36}nzcCaseStatus.fields.{02b1e5ad-db00-4b4c-a86a-6ca557c5eec3}label']
                      ),
                      color: fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{59de7399-85e5-4db2-ae13-1590f2955b36}nzcCaseStatus.fields.{9eae4879-2cfd-43db-a72c-1e641646e807}color'],
                      size: if(
                        a!isPageWidth("PHONE"),
                        "MEDIUM_PLUS",
                        "STANDARD"
                      )
                    ),
                    a!richTextItem(
                      text: " " & if(
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{c352c6b4-4199-4eb5-b473-0b268648cb10}statusId'] = cons!NZC_TASK_GROUP_STATUS_ID,
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{d644a43d-f482-4b9b-99fb-a9052050e902}nzcTaskGroup.fields.{922c5189-6e56-4af0-896e-ee1319da2ff0}name'],
                        fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{59de7399-85e5-4db2-ae13-1590f2955b36}nzcCaseStatus.fields.{02b1e5ad-db00-4b4c-a86a-6ca557c5eec3}label']
                      ),
                      showWhen: not(a!isPageWidth("PHONE"))
                    )
                  },
                  preventWrapping: true
                ),
                align: if(
                  a!isPageWidth("PHONE"),
                  "CENTER",
                  "START"
                ),
                width: if(
                  a!isPageWidth("PHONE"),
                  "NARROW",
                  "MEDIUM"
                )
              ),
              a!gridColumn(
                label: "Creator",
                sortField: 'recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{9405aee9-2e36-4ccf-84fa-b1a090f1eb39}createdBy',
                value: a!richTextDisplayField(
                  value: {
                    a!richTextItem(
                      /* Change this when we hook the relationship to technicians or w/e*/
                      text: a!localVariables(
                        local!pomSplit: proper(
                          split(
                            fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{a8983e1b-17a5-4d85-a3b4-1f4a9d8da959}nzcUtilityPlant.fields.{f0a402fa-db36-4741-ae56-e827ee79fdd0}plantOwner'],
                            "."
                          )
                        ),
                        if(
                          isusernametaken(
                            fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{9405aee9-2e36-4ccf-84fa-b1a090f1eb39}createdBy']
                          ),
                          user(
                            fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{9405aee9-2e36-4ccf-84fa-b1a090f1eb39}createdBy'],
                            "lastName"
                          ) & ", " & user(
                            fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.fields.{9405aee9-2e36-4ccf-84fa-b1a090f1eb39}createdBy'],
                            "firstName"
                          ),
                          local!pomSplit[2] & ", " & local!pomSplit[1]
                        )
                      ),
                      size: "MEDIUM"
                    ),
                    char(10),
                    a!richTextItem(
                      text: {
                        a!richTextImage(
                          image: a!documentImage(
                            rule!NZC_RegionImage(
                              regionId: fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{a8983e1b-17a5-4d85-a3b4-1f4a9d8da959}nzcUtilityPlant.fields.{7200577d-e5d9-422f-9807-5418d197c4d1}regionId']
                            ).flagImage
                          )
                        )
                      },
                      size: "SMALL"
                    ),
                    " ",
                    fv!row['recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.relationships.{a8983e1b-17a5-4d85-a3b4-1f4a9d8da959}nzcUtilityPlant.fields.{3bb890a3-03d3-417c-8649-affcafda7ab6}plantName']
                  }
                ),
                align: "START",
                width: if(
                  a!isPageWidth("PHONE"),
                  "NARROW_PLUS",
                  "AUTO"
                )
              )
            },
            showWhen: or(
              ri!showTextField = false(),
              a!isNullOrEmpty(ri!showTextField)
            ),
            selectable: true,
            selectionStyle: "ROW_HIGHLIGHT",
            selectionValue: ri!id,
            selectionSaveInto: { ri!id, a!save(ri!showTextField, true) },
            validations: {},
            refreshAfter: "RECORD_ACTION",
            showSearchBox: true,
            showRefreshButton: true,
            recordActions: {
              a!recordActionItem(
                action: 'recordType!{432051af-6600-4300-be7c-4ccc4886d2c8}NZC Case.actions.{368a6eb7-f045-4f57-9804-abc4ee6ee6b9}newCase'
              )
            }
          )
        }
      )
    }

  • 0
    Certified Associate Developer
    in reply to Mathurambika M

    Mathurambika,

    I believe the reason my grid does not maintain the current page is because it is refreshed using the refreshOnVarChange parameter. This appears to reset the paging of the grid. I have edited the original question to include my grid SAIL code.

  • 0
    Certified Lead Developer
    in reply to Jack Ferguson

    Okay, understood. After the changes are made, I believe that you are updating the record using the 'Write Records' smart service/function. In this scenario, do you actually need to configure 'refresh on variable change,' or is it not already handled by 'refreshAfter: RECORD_ACTION'?

Reply Children