Grid |
Step 6: Field Layout |
The Add a Webster+ Grid window is used to add (and edit) a Grid control on the file maintenance HTML page only. It is not available for file maintenance NOMADS panels.
(The ability to add/edit a Grid was added in PxPlus 2022.)
To invoke this window, use one of the following methods:
• Click the Add Object button (above the Layout Grid) and select the Grid option. OR
• Right click on a cell in the Layout Grid, select Add Object from the popup menu and then select the Add or Edit a Grid option.
The data entered in the Column Definitions grid is used to define the Webster+ [grid] and [col] short codes, which are needed to render a Grid on the generated HTML page. See Using Grids in Webster+.
For an example of a Grid definition, see Grid Example.
This window consists of the following:
Grid Variable |
Enter the name of the Grid variable that will be the handle to the memory file used to load the Grid. The Grid must be associated with an HTML Interface Program (entered in Step 1: Definition) that contains a method for loading the Grid using a memory file. The HTML interface program must contain the method: LOAD_xxxx Where: xxxx (case insensitive) is the Grid Variable entered (e.g. ADD_GRID_1). For an example of a Grid definition with a sample Load_MyGrid method, see Grid Example. The Grid Variable defaults to ADD_GRID_1, ADD_GRID_2, etc.; however, it can be changed to any numeric variable. Other events that are associated with entering values in the Grid at run time are also added to this interface program. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Size |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Appearance |
(Header Class was added in PxPlus 2022 Update 1.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Interfaces |
(Initialization Program was added in PxPlus 2022 Update 1.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Column Definitions |
The data entered in the Column Definitions grid is used to define the Webster+ Short Codes on the generated HTML page. For each column to be added to the Grid, define a new row with the following details:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Insert Above |
Adds a blank row above or below the currently selected row for creating a new column. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Delete |
Removes the currently selected row, which also removes the column from the Grid being defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Move Up |
Changes the order of the existing columns in the Grid being defined. |
The example below shows a Grid definition with eight rows of data entered in the Column Definitions grid:
• |
Rows 1, 2, 3 and 5 define columns that are based on the SalesRepCode, Name, ImagePath$ and ytdOrders fields in the Salesreps data file. |
• |
Row 4 defines a column that is based on the Department data class. |
• |
Rows 6, 7 and 8 define columns that are based on Simple Variables named email$, image$ and comments$. |
The following program, which contains an event (Mail) and a method to load the grid (Load_MyGrid), was defined as the HTML Interface Program:
! grid_interface demo program
!
goto lno(_event$,err=*next)
%webster'msgbox("Invalid event: "+_event$,"Internal Error - "+pgm(-3),"!")
exit
!
Mail:
! code needed when Mail button is pushed
%webster'msgbox("Pushed Mail button","Button event","!")
exit
!
Load_MyGrid:
enter MyGrid
if MyGrid<>0 \
then exit
open (hfn,iol=*)"salesreps"
reps=lfo
open (hfn,iol=MyGridIOL)"*memory*"
MyGrid=lfo
select * from reps
write (MyGrid)
next record
close (reps,err=*proceed)
exit
!
MyGridIOL: \
iolist SalesRepCode$,Name$,ImagePath$,Department$,ytdOrders,Email$,Image$,Comment$
When the HTML file is generated, the Webster+ short codes for this Grid look like this:
[grid MyGrid program="test_interface;Load_MyGrid" gridlines size=Auto/10 class=""]
[col width=5 ttl="Drag" align=center event=*Rowdrag][symbol reorder][/col]
[col usefile=Salesreps source=SalesRepCode$ ttl="Sales Rep Code" width=20 align=left class=bold,text_red]
[col usefile=Salesreps source=Name$ ttl="Name" width=25 align=left]
[col ttl="Image" width=6 align=center][picture file=(ImagePath$) size=6/2][/col]
[col ttl="Department" width=24 align=left][list Department$ dataclass=Department program=*class;ClassList,"Department"][/list][/col]
[col usefile=Salesreps source=ytdOrders ttl="YTD Orders" width=15 align=right locked]
[col ttl="Send Email" width=12 align=left][button email$ size=auto size=11/1.5 event=mail][symbol envelope] Email[/button][/col]
[col ttl="Fixed Image" width=12 align=left][picture size=auto file=*plus/inomads/sysimage/book_open.png][/col]
[col source=comment$ ttl="Comment" width=20 align=left tip="Enter Comment"]
[col width=4.5 align=center ttl="Del"][symbol trash event=*Rowdel][/col]
[/grid]
In Webster+, the Grid looks like this:
This Grid shows the following, based on the Grid Definition:
• |
The Drag column is shown because the Include Drag Column check box was selected. |
• |
The Grid is loaded with records from the Salesreps file in the data dictionary. All the columns are populated, except for Comments, which is not a field in the Salesreps file. |
• |
The Sales Rep Code column contains a query button because the SalesRepCode$ field was defined with a query in the data dictionary. The data in this column is red and bolded because a class was entered in the Other Options column. |
• |
The Image column was defined with a Cell Type of Image and contains the image referred to in the ImagePath$ column of the Salesreps file with a width of 6 and a height of 2. If no size was specified in the Other Options column, the cell would be made large enough to fit the image. |
• |
The Department column shows a drop-down arrow in each cell because the Department data class was defined for a Drop Box control, which the Cell Type column indicates. |
• |
The YTD Orders column is locked because the ytdOrders field was defined as Read Only in the data dictionary. The data in this column is right aligned because Right was selected in the Align column. |
• |
The Send Email column shows a button in each cell because Button was selected in the Cell Type column. The button's size, symbol, text and event are based on the text, symbol, size and event options that were entered in the Other Options column. When the button is clicked, the mail event in the HTML interface program will be triggered. This needs to be coded to determine the email address and launch the email program. |
• |
The Fixed Image column is defined with a Cell Type of Image and displays the file specified in the Other Options column in all rows of the Grid. |
• |
The Comments column shows a tip when you hover over it because a tip option was entered in the Other Options column. |
• |
The Del column is shown because the Include Delete Column check box was selected. |