How to configure the number of pages of the paginationBar, when the grid is loaded with variables

 

When working with variables, when loading data into the grid, it may turn out that the PaginationBar shows only one page, preventing all records from being seen in the grid, as we see in the following image:

 

Generated WorkWithPlus grid shows a Nickname column header dropdown menu open with options Sort from A to Z, Sort from Z to A, Fix to the left, Fix to the right, and a search box listing checkable name values with counts such as Mery (1), Mike (8), Mikey (3), Nick (11), and Paul (1); grid rows list Nickname, Birth Date, Hobby, Gender, and Company columns.

 

This is due to the different ways that can be used to load variables, which also depend on navigation and filters.

 

Instructions to have a correct paging:

 

To show the correct number of pages, the variable &GridPageCount of the paginationbar must be loaded manually with the number of pages that should exist.

A Work With Plus web form layout diagram shows the paging control area (Action Group, filter text box &FilterFullText, ErrorViewer, Grid with Level Id/Level Name columns, and a paging slider control) highlighted in a red box, with an arrow pointing to the Properties panel's Data Binding section where 'Page Count' is bound to the variable &GridPageCount.

 

You can load this variable from the refresh event as I show below:

A GeneXus code editor shows the Event Refresh block containing an If Block, followed by code that sets &RecordCount to Grid.RecordCount and computes &GridPageCount using &RecordCount divided by Grid.Rows with an iif/Mod adjustment for the remainder.

&RecordCount = Grid.RecordCount 
&GridPageCount = &RecordCount/Grid.Rows + iif(Mod( &RecordCount, Grid.Rows)>0,1,0)

 

This is an example of how it can be loaded, where we use an auxiliary variable(&RecordCount) to count the number of records, and based on them, calculate the number of pages for the pagination bar.

The count of the total records will depend on how the variables are being loaded, so the logic may vary, the important thing is to set the total records of the grid in the variable &RecordCount.