Uniface Sample: Grid

Uniface 9.6.01
Sample Version: 1.0
October 2013

Demonstrated Functionality

This sample shows how you can use the various features of the Grid widget. It demonstrates:

The sample shows:


This sample consists of the following files:

File name



This file


Uniface export file containing:

  • Form U96_GRID, the main form
  • Form U96_GRID_EMP, the employee tab
  • Form U96_GRID_DEP, the department tab
  • Form Template U96_GRID_TPL, the template for the tab forms
  • Model U96_GRID, the application model
  • Library U96_GRID, for the Incude proc and the Popup menu


Test data


Pictures that are used in the sample


Pictures that are used in this readme

Knowledge Prerequisites

To use this sample, knowledge of the following topics is assumed:

Uniface Subject

Knowledge Level

Uniface development


Uniface Proc code



  1. Add the following line as the first line in the [FILES] section of your IDF assignment file.
    u96*.*     .\samples\u96*.*
  2. Create a subfolder samples in your projects folder.
  3. Unzip file u96_grid.zip and place its files in your samples folder.
  4. Import the Uniface sources and the test data.
    /imp u96_grid*.xml
  5. Compile the Uniface sources.
    /all u96_grid*
  6. Depending on your deployment configuration you may need to update your URR.
  7. Run the sample from outside the IDF
    /tst u96_grid
  8. Test the form.
    • Press the right mouse button and explose the options.
    • Click the column headers to change the sorting.
    • Select some rows and use the popup menu to manipulate them.
    • Examine the forms in the Component Editor.


When the user clicks a column header the Grid will be sorted on that column.
When you click again it will switch between an ascending and descending sort order.
The sorting of the Grid is implemented in the extended trigger ColumnHeader_LClicked of the grid.
To improve re-use of the code it has been placed the Include Proc U96_GRID:U96_GRID.
Additionally it uses the Component Variable SORTORDER.
NB: Sorting will complete the hitlist, so please only implement sorting on Grids that contain a limited amount of rows.

Sorting on Representation

A common issue is that the user expects columns to be sorted on the representation while the default behavior is that it will be sorted on the value.
This sample shows one possible implementation of sorting on the representation. The entity has non-database columns that will be filled with representation in the Read and the Value Changed triggers. In the Defines trigger of the component you specify which columns need to be sorted on which dummy columns in the ALTSORTCOLUMNS constant.
NB: Sorting will complete the hitlist, so please only implement sorting on Grids that contain a limited amount of rows.

Hiding and showing columns

When the user right-clicks in the grid a popup menu appears where he or she can control which columns are visible.
This is implemented using the Popup menu and the operations opCreateMenu and opToggleColumn.
To improve re-use of the code the operations are on the Form Template U96_GRID_TPL.
Hiding and showing an autosizable column does not work well, so hiding and showing has been disabled for autosizable columns.


The user can select multiple rows in the grid by clicking on the row headers with the usual click, shift-click and control-click combinations.
The top left of the grid can be clicked to select all the rows.
Right-clicking in the grid brings up the popup menu that contains actions that can be performed on the selected rows.
The selecting mechanism is implemented in the extended triggers RowHeader_LClicked and CornerButton_LClicked of the grid.
The code can be found in the Include Proc U96_GRID.

Copy,Paste,Cut of rows

After the user has selected one or more rows he or she can use the Popup Menu to perform actions on those rows.
In the predisplay triggers of the menu options the options are enabled or disabled.
The Predisplay triggers and Option triggers activate operations that can be found in the Operations trigger of the Form Template.

More Information