• <Helps for GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • 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
        • Report Function (Deprecated)
        • SaveSetting Function
        • SetLanguage Function
        • SetProperty Function
        • SetReportData Function (Deprecated)
        • SetValueSet Function
        • SetValueSet Function With Arrays
        • 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
      • Export Attributes
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Appendix
  • <Helps for CSEntry>
  • <Helps for CSBatch>
  • <Helps for CSTab>
  • <Helps for DataViewer>
  • <Helps for TextView>
  • <Helps for TblView>
  • <Helps for TRSWin>
  • <Helps for CSDeploy>
  • <Helps for CSPack>
  • <Helps for CSFreq>
  • <Helps for CSSort>
  • <Helps for CSExport>
  • <Helps for CSReFmt>
  • <Helps for CSDiff>
  • <Helps for CSConcat>
  • <Helps for TRSSetup>
  • <Helps for ParadataViewer>
  • <Helps for ParadataConcat>
  • <Helps for CSIndex>
  • <Helps for Excel2CSPro>
  • <Helps for CSWeb>

HtmlDialog Function

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.
Format
s = htmldialog(html_filenameʃ, input_dataʅ);
s = htmldialog(html_filename,
               
ʃinputData := input_data,ʅ
               
ʃdisplayOptions := display_optionsʅ);
Description
The htmldialog 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.
Return Value
The function returns a string. The contents of the string are determined by the HTML template and returned by a JavaScript call to CSPro.returnData().
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 string contents of the input data are retrieved by calling CSPro.getInputData() from the script block of the HTML template.
// Simple string
var inputString = CSPro.getInputData();

// JSON string
var inputJSON = JSON.parse(CSPro.getInputData());
Display Options
The display options can be set using the optional named argument display_options in CSPro logic, or can be specifed as part of the HTML dialog by executing a JavaScript call to CSPro.setDisplayOptions(displayOptions).
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 resizeable 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 CSPro.setDisplayOptions(displayOptions). 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, JavaScript Interface