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
  • +1
    Certified Lead Developer

    Store your PagingInfo in a local variable and use that instead of using the built-in paging via the grid configuration.  That way it'll be persisted until the form is hard-reloaded at the very least.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    Mike,

    Where in the gridField component would I use the saved paging info? I can't find any parameter that seems to allow me to do that.

    I have updated the original question with the code for my grid component.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    I was afraid of that. I do have a user filter that I use with this grid, but I could always recreate it outside the grid if I need to (it'll just look a little less clean). I'm going to try and test using record actions from the grid to update the data, and see if that solves my problem. If it doesn't, I'll try doing as you suggested.

  • 0
    Certified Associate Developer
    in reply to Jack Ferguson

    I attempted to adjust the grid as you suggested (using a local variable as the data source and another one to store paging info), however, I'm still unsure how to use the paging info to get the result I'm looking for. If I use the paging info in the data source local variable the grid is reduced to one page since the batch size of the grid is 10. If I just use the start index, the user can never go back to previous data since the query won't pull it.

    Do I need to create my own back/forward buttons to control the grid?

  • 0
    Certified Lead Developer
    in reply to Jack Ferguson
    Do I need to create my own back/forward buttons to control the grid?

    the built-in paging controls will work for this as long as you point your "pagingSaveInto" parameter at the Paging Info local variable you've set up.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    Then how do I use that local variable to set the page of the grid? The "pagingSaveInto" parameter only saves the paging info to that local variable, it doesn't affect the paging of the grid. The only way I can see to affect the page of the grid with that paging info is to use the paging info in the local variable that provides the data to the grid, so that it only pulls that data for the current page, then adjust that with custom grid navigation buttons.

    Am I missing something?

  • 0
    Certified Lead Developer
    in reply to Jack Ferguson
    The "pagingSaveInto" parameter only saves the paging info to that local variable, it doesn't affect the paging of the grid.

    It will as long as you've correctly used the paging info local variable as the paging info for your query that you're using as the grid's data source.

    Mind posting a code snippet of what you're currently trying?

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    local!gridPagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 10
    ),
    local!gridData: a!queryRecordType(
        recordType: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp',
        fields: {
          'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{25c9c265-5e3b-4b03-8f40-9e09e788b815}adviceid',
          'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{351098f2-3bd8-40ca-9d8f-2ce3c5162466}equipId',
          'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{43147ee1-1b62-4046-bf12-31195409a794}recFlushPlan',
          'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{8aed024e-4792-4f66-9cac-799c04f5838e}recComments',
          'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.relationships.{ffc37494-c395-4c92-abf4-ee496a2ea7fb}samsSurveyData.fields.{5898e6c1-9b33-4563-a3f8-5e8b77733da3}serviceDescription'
        },
        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
        ),
        pagingInfo: local!gridPagingInfo,
        fetchTotalCount: true()
    ),

    Above is the code for my two local variables. "gridPagingInfo" stores the paging info from the grid and is currently configured with a hard coded starting value to prevent an error on first load. "gridData is used as the data source for the grid.

    a!gridField(
        label: "Recommendation Grid",
        labelPosition: "COLLAPSED",
        data: local!gridData.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']
          )
        },
        /*userFilters: {*/
          /*'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.filters.{3163b259-e8f7-4c1c-87be-c3dd00a7bfbf}recTemp_RecStatusFilter'*/
        /*},*/
        /*showSearchBox: true,*/
        /*showRefreshButton: true,*/
        pageSize: 10,
        initialSorts: a!sortInfo(
          field: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp.fields.{351098f2-3bd8-40ca-9d8f-2ce3c5162466}equipId',
          ascending: true()
        ),
        pagingSaveInto: {
          a!save(
            local!gridPagingInfo,
            fv!pagingInfo
          )
        },
        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: "STANDARD",
        refreshOnVarChange: local!gridUpdate,
        refreshAfter: "RECORD_ACTION"
      ),

    Above is the code for my grid currently.

  • 0
    Certified Lead Developer
    in reply to Jack Ferguson

    AFAIK you shouldn't be putting ".data" here - you want the grid to consume the entire query result, which contains extra metadata describing the current paging/etc.  This *might* be what's messing you up so far.

    You also wouldn't need the "pageSize" parameter in this configuration since the pagingInfo handles that.  You also wouldn't pass in an "initial sorts" value - that would also be passed into local!gridPagingInfo if needed.

    And this part is wrong (or at least overwrought).

    It should jus be: "pagingSaveInto: local!gridPagingInfo"

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    Removing the ".data" from the data parameter cause that grid to display a single empty row with the way the column values are currently configured. I have not been able to find a way to get the data to populate correctly without that ".data". I'm also not sure how the grid would use the other meta data contained within that variable. I've attached an image of the variable contents below

    The pagingSaveInto parameter is that way because I was exploring the difference between "fv!pagingInfo" and "fv!currentPage"

  • 0
    Certified Lead Developer
    in reply to Jack Ferguson
    Removing the ".data" from the data parameter cause that grid to display a single empty row with the way the column values are currently configured.

    sorry, i forgot, there's a bug in the Paging Grid component where it won't accept a the "map"-typed DataSubset returned by QueryRecordType without manually casting it as a DataSubset (grumble).  Luckily this is pretty easy.

    local!gridData: cast(
      typeof(a!dataSubset()),
      a!queryRecordType(
        recordType: 'recordType!{100a00b9-8c15-4fca-8f8e-00c7044acb96}SR RecommendationTemp',
        fields: {  ...

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    That did it! My grid is now updating while maintaining the current page! 

    Thanks so much!

Reply Children
No Data