• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
        • Compress Function
        • Decompress Function
        • diagnostics Function
        • Encode Function
        • ErrMsg Function
        • ExecSystem Function (Desktop)
        • ExecSystem Function (Mobile)
        • ExecPFF Function
        • GetProperty Function
        • GetLabel Function
        • GetLanguage Function
        • GetSymbol Function
        • GetValueLabel Function
        • hash Function
        • htmldialog Function
        • InValueSet Function
        • Invoke Function
        • IsChecked Function
        • loadsetting Function
        • LogText Function
        • MaxValue Function
        • MinValue Function
        • paradata Function
        • PathConcat Function
        • PathName Function
        • savesetting Function
        • SetLanguage Function
        • SetProperty Function
        • SetValueSet Function
        • SetValueSets Function
        • Special Function
        • sqlquery Function
        • Stop Function
        • SysParm Function
        • tr Function
        • Trace Function
        • UUID Function
        • View Function
        • Warning Function
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

htmldialog Function

Format
s = htmldialog(html_filenameʃ, input_dataʅ);
s = htmldialog(html_filenameʃ, inputData := input_dataʅʃ, displayOptions := display_optionsʅ);
Description
The htmldialog function allows for the customization of CSPro dialogs in two ways. First, HTML templates can receive dynamic input data from the CSPro application which can be used as text in the dialogs or to change the behavior of the dialog. Second, user-created HTML templates give the application developer complete control of the appearance and behavior of the dialogs.
The function must be passed a a string expression, html_filename, that specifies the HTML template to be used for the dialog.
In the first version, the optional string expression input_data argument allows input data to be passed to the HTML template.
In the second version, the optional named argument input_data allows input data to be passed to the HTML template. The optional named argument display_options argument is a JSON string that allows control of the display settings. All possible display options are shown below in a table.
You can use CSCode to design and test HTML dialogs. HTML dialogs can also be shown using the UI.showDialog function.
Return Value
The function returns a string. The contents of the string are determined by the HTML template and returned by a JavaScript call, using the Action Invoker, to UI.closeDialog.
HTML Templates
CSPro includes HTML templates in the installation folder for the dialogs it uses. User-created HTML templates allow for further customization of the dialogs. When the htmldialog function is called, the html_filename is first searched for in the current application directory. If not found and a HtmlDialogs directory override is specified in the PFF file, that directory is searched. If a match is still not found, then the directory html/dialogs in the CSPro installation folder is also searched.
Writing a user-created HTML template can be simplified by first selecting an existing HTML template that is most similar to the planned dialog. Make a copy of this HTML template in the current application directory and extend it to fit the new dialogs requirements.
Input Data
The input data argument is a mechanism to pass data from the CSPro application to the HTML template. The contents of the input data could be a simple text string that represents a single value or a JSON string that represents multiple values. The contents of the input data are retrieved by calling the UI.getInputData action from the script block of the HTML template.
const inputData = CS.UI.getInputData();
Display Options
The display options can be set using the optional named argument display_options in CSPro logic, or can be specified as part of the HTML dialog by calling the UI.setDisplayOptions action.
NamePlatformValues
widthBothWidth in display units
heightBothHeight in display units
resizableWindowsTrue, False
borderColorWindowsCSS name or hex code (e.g., "black" or "#000000")
titleBarColorWindowsCSS name or hex code
titleBarHeightWindowsHeight in display units
keyboardAndroidTrue, False (whether to show an on-screen keyboard)
The default values for resizable and keyboard are false. If a width and height are not specified, CSPro will wait a few seconds before showing the dialog as it expectantly waits for a call to UI.setDisplayOptions. This behavior is undesirable so it is important to specify the dialog width and height.
Example: Existing HTML Template
string input_data = '{ "title": "Enter Some Data!",'
                   
'  "multiline": true,'
                   
'  "allowEmptyText": false }';

string result = htmldialog("text-input.html", input_data);
Example: User-Defined HTML Template
string input_data = "Hello world!";
string display_options = maketext('{ "width": "%d",'
                                 
'  "height": %d,'
                                 
'  "borderColor": "#FF0000" }',
                                 
tonumber(getproperty("MaxDisplayWidth")) * 0.8,
                                 
tonumber(getproperty("MaxDisplayHeight")) * 0.8);

string result = htmldialog("user-defined-dialog.html",
                           
inputData := input_data,
                           
displayOptions := display_options);
See also: HTML in CSPro, Action Invoker Execution from JavaScript Run from Web Views, UI.showDialog Action