HTML Properties
The HTML presentation object is used to display customlly written HTML content insi QPR MobileDashboard views. HTML presentation objects are able to interact with context variables. Main differences to External Content presentation object are follows:
- External content is basically a link to an external web page that resides outside QPR MobileDashboard. HTML presentation object settings contains the needed HTML code, and thus the content is stored to QPR MobileDashboard and transfered when exporting and importing views. Still, the HTML code may refer to external resources in web, but that should be avoided so that views are easily deployable.
- External content presentation object is not able to draw outside its area in the view. This is because External content presentation object is tecnically an iframe, and browsers don't allow iframes to draw to its parent window area. HTML presentation object is able to draw outside its content area.
- The HTML code in the HTML presentation object is not an entire web page but an HTML block, such as a DIV tag. External content presentation object needs to link to full web page (starting with HTML tag).
Properties Tab
The following properties can be set on the Properties tab:
- Name: Name of the HTML presentation object. The name is not visible in the dashboard.
- Description: Description for the HTML presentation object. The description is not visible in the dashboard.
Presentation Tab
The following settings can be set on the Presentation tab:
- HTML code contains the HTML that will make up the displayed HTML content. Also CSS and JavaScript blocks can be used. You can also use context variables in the HTML code. If the used context variable values change, the HTML presentation object is initialized and possible stored state in JavaScript variables in the code are lost.
- Horizontal / Vertical scrollbar defines how the horizontal or vertical scrollbar is shown for the HTML presentation object. Options are:
- Auto: Scrollbar is visible if the content is scrollable (i.e. HTML presentation object height is greater than the available area for the presentation object in the view). Scrollbar is hidden, if the content is not scrollable. Setting width may be more difficult as width depends whether the scrollbar is shown.
- Visible: Scrollbar is always visible. If the content is not scrollable, the scrollbar is grayed.
- Hidden: Scrollbars is never shown. This setting can be used when the HTML presentation object should not contain scrollbars to prevent the scrollbars appearing in any case. If the height of the HTML presentation object is greater than the available area in the view, rest of the content is not accessible.
Callback functions in HTML code
In the HTML code the following callback functions may be defined:
- function <#contextChangeFunction>(changedContextVariables): This function is automatically called by QPR MobileDashboard when the effective context of the HTML presentation objects changes. The changed context variables are available in the changedContextVariables parameter as key-value pairs. This function is also called once when the HTML presentation object is initialized (the view is loaded). Use this function to write custom logic that should occur in the HTML presentation object when context variables change.
- function <#resizeFunction>(newWidth, newHeight): This function is automatically called by QPR MobileDashboard when the HTML presentation object size changes, for example as a result of changing browser window size. The function is needed, if the resize logic needs to be written using JavaScript. This function is called also once when the HTML presentation object is initialized (the view is loaded).
Notes:
- These functions need to be defined inside script block.
- The actual function names are not known in view design time and that's why the tag syntax is used. QPR MobileDashboard will replace the tags with the actual function names during HTML presentation object is rendered. This is also to guarantee that the function names are unique when there are same HTML code used multiple times in the view.
- These functions are not called when the HTML presentation object is hidden (using the How in view setting).
Example HTML code
This is an example is a simple customized presentation object which shows a value from a context variable measureValue. If the context variable value is changed, the new value is updated to the HTML presentation object.
<div id="content"><div> <style> #content { font-size: 20px; font-weight: bold; } </style> <script> function <#contextChangeFunction>(changedContextVariables) { if (changedContextVariables["measureValue"] != null) { $("#content").text(changedContextVariables["measureValue"]); } } function <#resizeFunction>(newWidth, newHeight) { if (newWidth < 100) { $("#content").css("margin-left", "0px"); } else { $("#content").css("margin-left", "20px"); } } </script>
Add an HTML Presentation Object
HTML presentation object is added to a view like adding the SVG presentation object, but instead of SVG presentation object select the HTML presentation object in the toolbar. You can use the example HTML code defined above. Note that HTML presentation objects don't contain actions like SVG presentation objects.