=load( local!pagingInfo:a!pagingInfo( startIndex: 1, batchSize: local!selectGrid, sort: a!sortInfo( field: "dataCorrectionRequestIdentifier", ascending: true() ) ), local!gridSelection: a!gridSelection( pagingInfo:local!pagingInfo ), with( local!datasubset: if(local!poDataToLoad.totalCount=0,{},todatasubset(local!poDataToLoad.data,local!gridSelection.pagingInfo)), /* When ever you interact (sort or paginate) with grid, the pagingInfo of local!gridSelection will be modified. In order to see the results of your actions on grid, the local!gridSelection should be applied to the data which you provide to the grid. The pagingInfo you provide initially to queryEntity is just to fecth the data based on the startIndex and batchSize, and thereafter sort it based on sortInfo. But when you provide the data to grid, whatever interactions (sorting or paginating) you make with the grid, should be applied to the data provided to grid i.e. todatasubset(,) */ { a!sectionLayout( label: "", firstColumnContents: { a!dateField( label: "From:", labelPosition: cons!PFDC_LABELPOSITION, value: ri!searchPFDC.DCCreatedFromDT, saveInto: ri!searchPFDC.DCCreatedFromDT ), a!dateField( label: "To:", labelPosition: cons!PFDC_LABELPOSITION, value: ri!searchPFDC.DCCreatedToDT, saveInto: ri!searchPFDC.DCCreatedToDT ), a!textField( label: "Freddie Mac Loan Number:", labelPosition: cons!PFDC_LABELPOSITION, align: "LEFT", value: ri!searchPFDC.fmLoanNumber, saveInto: ri!searchPFDC.fmLoanNumber ) }, secondcolumncontents: {} ), a!sectionLayout( label: "", firstColumnContents: { a!buttonLayout( primarybuttons: { a!buttonWidget( label: "Search ", validate: true(), validationGroup: "searchPFDC", value: "searchPFDC", saveInto: {local!searchAction, a!save(local!loanCount,0), a!save(local!selectedLoans,null), a!save(local!gridSelection.selected,null), /*We need to reset the pagingInfo again as the local!poDataToLoad is loaded with fresh data when 'Search' button is clicked i.e. the previous paging info contained in local!gridSelection should be cleared and reset.*/ a!save(local!gridSelection.pagingInfo,local!pagingInfo), a!save(local!poDataToLoad,rule!TestEntity(ri!searchPFDC,local!pagingInfo) ) } ) } ) }, secondColumnContents: {} ), if( local!searchAction = "searchPFDC", { a!gridField( label: "", instructions: "Total Selected :" & local!loanCount, totalCount: local!datasubset.totalCount, columns: { a!gridTextColumn( label: "Primary Borrower Last Name", field: "primaryBorrowerLastName", data: index( local!datasubset.data, "primaryBorrowerLastName", {} ) ), a!gridTextColumn( label: "Data Correction Identifier", field: "dataCorrectionRequestIdentifier", data: index( local!datasubset.data, "dataCorrectionRequestIdentifier", {} ) ), a!gridTextColumn( label: "Data Correction Creation Date", field: "requestCreateDateTime", data: index( local!datasubset.data, "requestCreateDateTime", {} ) ) }, identifiers: index( local!datasubset.data, "dataCorrectionRequestIdentifier", {} ), value: local!gridSelection, saveInto: { local!gridSelection }, selection: true ) }, {} ) } ) )