User Preference Persistence Backend runtime configuration


In interfaces generated using K2BTools the user is allowed to select the columns he desires in a grid and set how many rows per page he wants to see. By default this configuration is persisted in session and K2BTools provides procedures that the developer can extend in order to give an implementation of how these preferences are stored.

Since K2BTools 11, a module is provided by K2BTools, helping the developer to persist the configuration selected by the user. This information is stored in the database, so when the user returns to the application all the configuration previously selected will be remembered.

This module also allows advanced configuration, for example showing different  columns depending on the tenant of the application, or making global rules for an application that will be installed in different environments and should have a different default configuration in each environment.

Before reading this page we recommend reading how this module works.

Backend configuration UI

This module contains an UI that is intended for advanced users, allowing them to customize how all the users in the application view their grids.

To access this UI, when installing the module the developer should have included the module’s menu in the application’s main menu.

The available options are the ones shown below.

User preferences menu

Grid Columns User Configuration

Using this option, an advanced user can see column configurations for all users and grid in the application.

This configuration is initially empty, and new entries are created whenever a user saves the grid’s settings. If a user/grid combination does not appear in this option, the module tries to find an entry for that grid with an empty user. If such an entry does not exist, the visibility of the columns is determined using the Columns Visibility Rules and the configuration in the KB.

Visible columns configuration

Because of this, all entries with an empty user are treated as the default for that grid in cases where there’s no configuration associated with the current user.

When using this interface, an advanced user can perform three operations:

  1. Deleting configuration entries.
  2. Emptying the “User” in entries selected (using the checkboxes) by the user.
  3. Setting their current configuration as a default for all users.

The third option can be used to initially configure the module. To do this, the advanced user should configure all grids as desired through the application’s UI and then execute the action in this interface.

Visible Column Rules

This interface can be used to configure which columns should be visible by default when no configuration exists for the grid being shown.

Visible columns rules

Rules are defined as follows:

  • Rule Name: An identifier for the rule.
  • Description: An user friendly description of the intent for the rule.
  • Matching criteria / Value: The matching criteria is used to determine if the rule should be applied to a column. Possible values are “Column Name Matches” and “Regular Expression”. Using the first option, the value is compared with the column name and only exact matches are considered a match. Using the “Regular Expression” option, the value is used as a regular expression and the column name is matched against that regular expression.
  • Is Visible?: Determines how the rule should act (if the column should be set to visible or not).


  1. Regular expressions can be useful to match several columns with similar names (subtypes frequently can be matched like this).
  2. For each attribute, the backend first looks for exact matches. If no matches are found, matches using a regular expression are used.

Rows Per Pages

This interface can be used to configure the default page size for grids in the application. Each entry can specify a tentant code, a user code, the program and grid name, and the rows that the grid should have.

Page size rules

When a user saves the grid page size through the application’s UI, a new entry is generated using all these fields.

When the application is loading a grid and needs to know the page size for it, the logic tries to match the data for the user and the grid to the entries available, this order:

Queries done to get page size for current user

Using this interface the user can create and delete entries. To simplify common tasks, two actions are included:

  1. Set Default Rows: Sets the value for the entry with all its fields set to empty.
  2. Set <Current User> Rows As Default: Sets the values for the current user as the default values for all users (by removing the value for the “User” column).