How to Override Grid Component Settings in an .a5w page or OnGridExecute event


Properties of the Grid Component can be overridden at run-time when the Grid is being loaded on an .a5w page or in the Grid Component's onGridExecute server-side event.

When a Grid Component is loaded, you can override some of the properties of the Grid Component using Xbasic. Many properties can be set at run-time, but some properties cannot (by default) without recalculating part or all of the Grid Component's layout. Properties that control the layout of the HTML, control definitions, or update settings are processed when the Grid Component is published to improve the initial load time for the Grid.

You can force the Alpha Anywhere Web Application Server to re-calculate parts of the Grid that are normally computed at design-time by setting a flag in the Grid Component's definition at run-time.

For example, say you want to override a column heading at run-time:

tmpl.field_info[3].Column.Heading = " is my column heading...."

This will not work because the column headings were computed at run-time.

However, it will work if you add this property:

tmpl.flagMustRecalculateGridLayoutAndControls = .t.
tmpl.field_info[3].Column.Heading = " is my column heading...."

In the above example, if your Grid is set to use a Form view, you can use the slightly faster tmpl.flagMustRecalcGridLayout property:

tmpl.flagMustRecalcGridLayout = .t.
tmpl.field_info[3].Column.Heading = " is my column heading...."

You can set the tmpl.flagMustRecalculateAllProperties property. This flag forces the Application Server to re-calculate the entire Grid Component at run-time. This can be quite slow and should be avoided if possible. It will delay the initial rendering of the Grid. Once the Grid is rendered, interacting with it will be back to normal speed. There will also be a similar delay when you interact with the Grid if your session expires and a new session needs to be instantiated.

The following flags are available:


Recaulculates the Grid Part layout.


Recalculates the Search Part layout.


Recalculates the Detail View layout.


Recalculates the entire Grid Layout and the controls in the Grid Part.


Recalculates the entire Detail View layout and the controls in the Detail View.


Recalculates the entire Search layout and the controls in the Search Part.


Recalculates the entire Grid Component layout. This is the slowest option and should only be used if none of the other flags work.

Overriding the Grid Component's SQL Query in the onGridExecute Event

If you override the grid's SQL select statement at runtime in the OnGridExecute event by setting the e.tmpl.CS.SQL property, you must also override the grid's refresh row query by setting the e.tmpl.precalc.sql_refreshRowQuery property.