Some tables require specifying custom HTML headers to match design requirements. Generally, these are multi-part tables with multiple rows of column headings, and thus do not match standard IntelliSurvey table heading output. To specify custom HTML table rows to build the heading area of a table, use the template_data
tag and headerrowhtml
parameter. This allows you to create as many rows of heading cells as is needed, and any configuration of row/colspans.
Syntax
The headerrowhtml
parameter targets the content inside the <thead>
tag in the table's HTML and replaces it with HTML specified by the Survey Programmer (SP). Let's add a brief desc. of the <thead> tag before this sentence.
The following code block shows examples of both inline syntax and heredoc syntax. When using headerrowhtml
, heredoc syntax is generally recommended, as HTML tables can quickly become difficult to read and write without line breaks. Notice that separate heredoc delimiters are needed for both the template_data
tag and the headerrowhtml
parameter inside it ('END' and 'ENDTD'). Also notice that the inline syntax requires quotes around the input HTML, while the heredoc syntax does not.
# Inline syntax: template_data: { headerrowhtml= '<tr><td>Insert custom HTML here, inside single quotes</td></tr>' } # Heredoc syntax: template_data: <<ENDTD { headerrowhtml=> <<END <tr> <td>Use heredoc syntax</td> <td>For multiple lines of HTML</td> <td>To improve readability</td> </tr> END } ENDTD
Example
In this example, the survey design calls for category headings, with time frames beneath each heading. Note the use of the TIMEFRAMES list for the table's columns. The usage of headerrowhtml
overrides the default column headings that would have been created by the TIMEFRAMES list. However, in the survey data and reports, the TIMEFRAMES list items will be used for the table's columns.
Caution! Make sure that the displayed text in the header HTML matches up with the table's lists. Otherwise, the respondent's answers will not be stored in the correct fields. For instance, if the TIMEFRAMES list was randomized, the HTML would not be randomized to match, which would cause data errors.
To make the HTML more legible, heredocs are employed on both the template_data
tag and the headerrowhtml
parameter:
Let's upd. the SPL here -- use 'type: integer table', single line SCT, 'ifnotset: 0' instead of 'ifblank', and either 'datatype: whole' or 'range: 0-100' so it's positive input only.
Inline syntax
When not using heredoc syntax, the input HTML must be surrounded in quotes, such as single quotes:
template_data: {headerrowhtml => '<tr><td colspan=7 style="background: #FF9999; color: white">Just a test cell to prove that it\'s working!</td></tr>'}
Or Perl:
template_data: {headerrowhtml => q{<tr><td colspan=7 style="background: #FF9999; color: white">Just a test cell to prove that it\'s working!</td></tr>}}
Comments
0 comments
Please sign in to leave a comment.