Tutorial 2008-06: Modern Grid Control
Hydra 4GL supports modern Grid Controls for classic Screen Arrays. They also have the advantage of grid column resize by the user and button event rasing i.e. for re-sorting of the grid columns
Modern Grid Control
‘Hydra4GL’ 4.3 has improved the appearance, usability and functionality of traditional Screen Arrays with the introduction of the modern Screen Grids functionality.

Hydra allows the user to replace a traditional ‘Screen Array’ with a modern looking and behaving ‘Grid Control’.

1. How to change a screen array to a screen grid
To do this:
- Open the form (.per) file using the Hydra Studio form designer or any text editor
- In the ‘Instructions’ section of the form, change ‘SCREEN ARRAY’ to ‘SCREEN GRID’
- Save the form file, compile and deploy it.
--Done—
Example:
Change:
SCREEN RECORD sc_rec [3]
( formonly.act_date, formonly.act_activity, formonly.act_state )
To:
SCREEN GRID sc_rec [3]
( formonly.act_date, formonly.act_activity, formonly.act_state )
2. Column Header Labels / Grid Headers
Traditional screen array column headers are usually done by writing static text labels in the form ‘Screen’ Section or by embedding dynamic text labels.
Modern Grids use by default embedded grid column headers which can also support click events and grid column re-sizing.
2.1 To keep the old static text or dynamic text labels for the column descriptions, you should remove the modern grid column header buttons
To do this:
1. Open (or create) any script file which is linked to your project
2. Add the line:
?.?.removeGridHeadings: TRUE
Note: Using external grid headers are NOT recommended
2.2 To use the new grid column header buttons, you need to populate these with static text in the form file or by using dynamic functions.
To use static in the form embedded text do this:
1. Open the form (.per) file using the Hydra Studio form designer or any text editor
2. In the corresponding field definition within the Attributes section add the OPTIONS information i.e. OPTIONS=’Header’=’My Column Label’
3. Optionally, you can also assign a key or action event for the mouse click on the column header button label.
Example:
ATTRIBUTES
f1=my_table.my_field, OPTIONS=”HEADER='Date' KEY='F9' ”
2.3 Populating the grid headers with dynamic 4gl function calls can be done this way
To do this:
1. Ensure, that you have NOT got the following line in your script file
?.?.removeGridHeadings: TRUE
If you find this line, remove or comment it using a # character
2. In your 4GL source file which manages the grid (screen array) data population call the function fgl_grid_header() with the corresponding arguments for each grid column.
Syntax:
Fgl_grid_header(
“<form grid name>”,
“<form field name>”,
”<Column label>”,
”<Alignment>”,
”<Key or Action event name>”)
Example:
CALL fgl_grid_header("sa_cont_scroll","cont_id",get_string(350),"left","F13")
3. Grid Resize and store new layout settings

a) if the user is allowed to resize the columns using the mouse
b) if this new column size should be stored for future sessions
3.1 To allow / dis-allow grid resizing do this:
1. Open (or create) any script file which is linked to your project
2. Add the line:
?.gridAllowResize: TRUE or FALSE
3.2 To store the modified grid column width settings for future sessions do this:
3. Open (or create) any script file which is linked to your project
4. Add the line:
?.storeGridSettings: TRUE or FALSE
4. Highlighting a particular line in the grid
(works for modern grid and classic screen arrays)
1. In your 4GL source file which manages the grid (screen array) data population call the function fgl_dialog_setcurrline(5,l_scroll_operator_line_id) in the BEFORE DISPLAY STATEMENT
Example:
DISPLAY ARRAY l_operator_arr TO sc_operator_arr.*
ATTRIBUTES(CURRENT ROW DISPLAY = "BLUE, REVERSE") HELP 910
BEFORE DISPLAY
#The current row remembers the list position and scrolls the cursor automatically to the last line number in the display array – It will show the specified record (if possible) in the fifth line/row of the grid control.
IF l_scroll_operator_line_id IS NOT NULL THEN
CALL fgl_dialog_setcurrline(5,l_scroll_operator_line_id)
END IF
…
END DISPLAY
5. Exporting Of Grid Data
The Grid control functions offer the developer the opportunity to cater for Grid data export. Grid data can be passed on to other applications for further processing and reporting purposes.
Export Data Range
To export the data (range off or all data) of a grid control call the function fgl_grid_export()
Example:
CALL fgl_grid_export("sc_rec",1,100,"Clipboard","html")
The first argument is the screen grid name as defined in the form file.
The second and third argument is the range - to export all simply specify 1,9999
The fourth argument specifies the target location (file or clipboard)
The fifth/last argument specifies the format (cvs or html)
You can also filter the export by only exporting grid data, which are currently viewed in the grid. To do this, call the function fgl_grid_viewexport()
Example:
fgl_grid_viewexport("scr_contacts","file","csv",c://my_file.txt)
" missing at last line
at the very last line, the "" is missing around the filename,
should be "c://my_file.txt"
Yours Bernhard / Berlin / Germany