Omnis Technical Note TNGI0023 June 2008

Using $gridcolumn and $gridsection in Complex Grids

For Omnis Studio
By Götz Krija

On occasions, you may need to know which column and section a certain field is located in a complex grid. To find this out using the notation, you can use the properties $gridcolumn and $gridsection; note that these properties are not listed in the Notation Inspector.

You could place the following code behind a button on your window to report the column and section of a particular field in the grid.

; CompGrid is a complex grid on a window containing the field City
; Create local vars column (Char) and section (Char)
Calculate column as $cinst.$objs.CompGrid.$objs.City.$gridcolumn
Calculate section as $cinst.$objs.CompGrid.$objs.City.$gridsection
OK message {Field "City" is located in column [column] and section [section].}

The $gridcolumn property returns the column number, while $gridsection returns one of the following constants:

kGridRow
kGridColumnHeader
kGridHeader
kGridNone
kGridOther

Alternatively, you can place a more generic method behind the $control method of the window to trap clicks on any of the fields in the complex grid. Consider the following window:

Complex grid

The complex grid and the list variable supplying the data contain fields for Firstname, Surname, Age and City. The $mouseevents property for all the fields in the grid has been set to kTrue. The $control method for the window contains the following code, which uses the evMouseUp event to detect clicks on fields in the grid:

; Create local vars column (Char) and section (Char)
On evMouseUp
  Calculate column as
    $cinst.$objs.CompGrid.$objs.[$cobj.$name].$gridcolumn
Calculate section as
    $cinst.$objs.CompGrid.$objs.[$cobj.$name].$gridsection
OK message {Field [$cobj.$name] was clicked, located in column [column] and section [section].}

Click here to download a library containing this window: grid_section.zip (Studio 4.1 library, may require conversion for higher versions).