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
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' ) } ) } ) }
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.
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.
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.
I assume it might only work when you query your data into a local variable and use that as the grid's "data" source, as opposed to passing the record type directly into the grid. So first you'd set up one local variable to hold the pagingInfo, then you'd set up one to hold the QueryRecordType result, then that second variable gets set as the grid's data - it's slightly more complicated but not all that hard if your requirement is solid (it'll end up functioning a bit more like grids used to work in older versions).
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'?
Yes, the changes are written via a Write Records function. However this is not a record action initiated by the grid, so the refreshAfter: Record_Action does not not update the grid.
However, if I change how my interface works to utilize record actions to update the data, that may solve my problem. I may try to test that.
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.
I attempted to create a related action to update the record and use it in a "recordActionField" in the grid. While I got the record to update the grid did not update properly, even with "refreshAfter: Record_Action" enabled.
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?