GRIDPLUS2 - Date Selector Grid | ![]() |
||||||
|
GRIDPLUS Date Selector Grid |
In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS dropdown date selector command mode based on the calendar widget. This command mode is a "short cut" method to invoke the GRIDPLUS widget command mode with the default widget set create dateselectors. All of the normal widget command mode functionality can be used. For example creating other widget types.
This uses a simple syntax to create a grid of date selectors. The syntax is closely based on the GRIDPLUS Grid and Widget.
GRIDPLUS Date Selector Specific Item Options/Functionality |
See GRIDPLUS Widget Grid for a full list of item options/functionality.
GRIDPLUS Date Selector Mouse/Keyboard Bindings |
A single left-click anywhere on the date selector, or pressing the down cursor when the widget has focus, will post a dropdown calendar.
A single left-click anywhere on the date selector, or pressing the escape (Esc) key when the widget has focus, will unpost the dropdown calendar.
The following Keys are effective for a date selector field:-
Del | Clear the content of the date selector field. This option can be disabled using -dateclear. |
Cursor Down | Post dropdown calendar. |
Esc | Unpost dropdown calendar. |
Setting Default Value |
Date selector default values can be set to a specified date, today's date -or- a calculated date based on today's date. This option uses the same syntax as gpdate.
=@ | Date today. |
=+days | Date today + days. |
=-days | Date today - days. |
=>months | Date today + months. |
=<months | Date today - months. |
Example:
gridplus date .mygrid -title "My Grid" -wtitle "Defaults" { {"No Default" .date1} {"Today" .date2 =@} {"Add 7 Days" .date3 =+7} {"Add 12 Months" .date4 =>12} {"Subtract 2 days" .date5 =-2} {"Subtract 1 Month" .date6 =<1} {"Specified Date" .date7 =12/25/2011} } pack .mygrid
Invoking Commands When a Date is Selected |
There are two ways to specify commands to be invoked when a date is selected:-
Setting Date Selector Icon |
It is possible, using the *Gridplus.dateIcon option database value, to set an icon to replace the down-arrow in the date selector.
Example:
gpoptions dateIcon calendar_view_day gridplus date .mygrid -title "My Grid" -wtitle "Example" { {"Date One" .date1} {"Date Two" .date2} } pack .mygrid
Setting Day and Month Names |
Day and month names should be correct for the current locale. If this is not the case use the GRIDPLUS set command/mode to explicitly set the locale.
For Example:
gridplus set -locale de_DE
Example |
This section contains an example which illustrates the main GRIDPLUS date selector command mode features.
The following example assumes that the reader is familiar with the contents of the Grid/Layout and Widget pages. Information given on that page will not be duplicated here.
Note: The example assumes that the GRIDPLUS package has already been "required" and the commands imported.
Window:
Dropdown calendar posted...
Date selected using mouse...
Source Code:
Comments:
When using the GRIDPLUS date selector
command mode the "label" defines the text that will appear as a label to the associated date selector.
The cell item begining with a dot is the widget (date selector) ID. The date selectors are created with
names based on the name of the containing Grid and the widget ID.
For example: The for the ".mygrid" cell defined by "{"Date Two" .date2}"
a date selector widget is created with the name ".mygrid,date2". Please note that the
widget name does contain a comma - this is not a misprint!!
In ".mygrid" the widget IDs are to the right of the label text. This will create
date selectors which are to the right of the label text.
Date Selector Example
gridplus date .mygrid -title "My Grid" -wtitle "Example" {
{"Date One" .date1}
{"Date Two" .date2}
}
pack .mygrid
Reading and Setting GRIDPLUS Date Selector Values |
The values of the GRIDPLUS widgets are stored in a global array with a null name.
For Example:
global {}
For GRIDPLUS Date selector widgets the array element has the same name as the widget: Thus the value of ".date1" in ".mygrid" is referenced as "$(.mygrid,date1)".
The recommended method to set GRIDPLUS date selector values is to use the gpset command.
For Example:
gpset .mygrid,date1 07/12/2009
Note: The date must be in the format as defined by -dateformat. An incorrect format will result in an error when posting a dropdown calendar.