Display Page Count property in grids

Objective

In many cases, users need to know how many pages are available in a grid. For many grids, such as those with a base table, this information can be automatically calculated by K2BTools. However, depending on the type of grid, there are instances where the page count or the total number of records cannot be automatically calculated by K2BTools. Additionally, calculating the total number of records or pages can sometimes lead to performance issues. In such cases, the best approach is to disable the page count.

How it works

When the DisplayPageCount property is set to true, the page count functionality is enabled in the grid. Depending on the type of grid, the page count may be calculated automatically by K2BTools, or it may require manual implementation by the developer through a subroutine that returns the total record count. The behavior of this property varies depending on the grid type.

DisplayPageCountRunTime
Total number of pages in paiging bar

When the DisplayPageCount property is set to false, the total number of pages is not displayed. However, the user can still navigate through the grid to iterate through the pages.

DisplayPageCountFalseRunTime
Paging with "DisplayPageCount" set to "False"

Grids with base table

For grids based on a base table, the page count is calculated automatically. In these cases, K2BTools relies on the Grid.PageCount and Grid.RecordCount functionalities. However, there are situations where Grid.PageCount or Grid.RecordCount may lead to performance issues or may not behave as expected. For such cases, it is recommended to read Common issues with Grid.PageCount. These types of grids include all grids in K2BEntityServices and K2BPrompt patterns , as well as grids with a base table in WebPanelDesigner

Grids with an inferred for each

In these grids, whether the page count can be automatically calculated depends on the developer's implementation in the U_LoadRowVars subroutine. In this scenario, a new property called Display Page Count Strategy is available. It has two values:

  • Automatic (default)
  • ManagedByDeveloper

PageCountStrategy
Display Page Count Strategy

The developer should change this property to ManagedByDeveloper when U_LoadRowVars is used to exclude specific records from loading (i.e., when the &LoadRow_<GridName> variable is modified). If Display Page Count Strategy remains set to Automatic and &LoadRow_<GridName> is modified, K2BTools will display an error message in the UI. For details on resolving this, see the LoadRow variable has been set to false by the developer error documentation.

If the intention is to control record loading using U_LoadRowVars, we recommend using the LoadCondition property, which is considered during automatic record count calculation. When Display Page Count Strategy is set to Managed By Developer, refer to the Manually calculate record count section below.

Grids based on Data providers or Procedures

In these grids, whether the page count can be automatically calculated depends on the parameters of the data provider or procedure, as well as the developer's implementation of the U_LoadRowVars subroutine. If the data provider does not include paging parameters, the Display Page Count Strategy property becomes available. This property has two possible values:

  • Automatic (default)
  • ManagedByDeveloper

The developer should set Display Page Count Strategy to ManagedByDeveloper when the U_LoadRowVars subroutine is used to exclude specific records from being loaded (for example, when the &LoadRow_<GridName> variable is modified). If Display Page Count Strategy remains set to Automatic while the &LoadRow_<GridName> variable is altered, K2BTools will display an error message in the UI. For more information on resolving this issue, refer to the documentation on the LoadRow variable has been set to false by the developer error documentation.

If the data provider includes paging parameters, the developer is responsible for manually calculating the total record count. This process is described in the Manually calculate record count section below

Grids based on SDTs or Business Components

When Display Page Count is enabled, the ability to automatically calculate the page count depends on the Get SDT Or BC On Grid Paging property's value:

  • If set to false, K2BTools will load all records via the U_LoadSDT subroutine and automatically calculate both page and record counts.
  • If set to true, the developer must manually implement record count calculation. For guidance, refer to the section Manually calculate record count section below.

Grids with no base table

In these cases, the developer must implement the record count manually. The Display Page Count property is only available when Load Event Scheme is set to Managed By Developer. In this case, the record count code must be written manually in all cases.

Manually calculate record count

When Display Page Count is set to true and K2BTools cannot determine the page or record count automatically, the U_CalculateRecordCount subroutine must be implemented by the developer.

The total number of records should be returned using the &RecordCount_<GridName> variable. By default, the subroutine includes placeholder messages in the UI, which must be removed. For more details, see the Calculate record count subroutine must be implemented error documentation.

RecordCountSubroutine
U_CalculateRecordCount must be implemented by developer

Default value of Display Page Count property

The default value of the DisplayPageCount property can be configured in the following ways:

  • For “EntityServices” pattern generated objects, in EntityServices settings, in “Grid” -> “”WorkWithGrid” and “Grid” -> “SubWorkWith” in “DisplayPageCount” property, for “WorkWiths” and “SubWorkWiths”
  • For “Prompt” pattern generated objects, in K2BPrompt settings, “Grid” -> “PromptGrid” , “DisplayPageCount” property.
  • For “Web Panel Designer” objects in Web Panel Designer settings there is a “DisplayPageCount”related to the different types of grids.
    DefaultValueDisplayPageCount
    DisplayPageCount default value

When migrating from versions older from K2BTools 16.0 in grids without base table this property's value is automatically adjusted to preserve the behavior from the previous version in existing panels.

Availability

  • Grids with base table: Supported from the first versions of K2BTools.
  • Grids without base table: supported from K2BTools 16.0