1. Home
  2. Knowledge Base
  3. Customize Your Applications
  4. m-Painter
  5. Use Field Substitutions within HTML Attributes and Inline Styles

Use Field Substitutions within HTML Attributes and Inline Styles

Overview

m-Painter allows field substitution parameters within HTML attributes and CSS styles. This document will help to explain how m-Painter can be used with field substitutions.

Some HTML attributes accept any character data as valid. For example; “title”, “alt”, and “class” can be set to any text value. Other HTML attributes, however, require values from a delimited list or range. An example of this would be the attribute “align”, which for most elements accepts only the following values: left, center, right, justify. Upon rendering the page, a field substitution may be rejected by m-Painter as invalid when used for these types of attributes. However, many of these types of attributes have been deprecated in recent HTML specifications in favor of inline styles, and m-Painter will now correctly handle these substitutions in inline styles.

Conditionally Set an Attribute

Sometimes you may wish to conditionally set an attribute within the HTML based on the data in your dataset. You may want to justify your data “center” or “right” depending on a value within the record.

Problem: m-Painter will reject the use of field substitutions when used with an attribute such an “align”:

< td align="${row.CALCULA001}">${row.FLD1}</td>

Because ${row.CALCULA001} is not a valid value for the “align” attribute it is rejected and removed by m-Painter.

Solution: The appropriate way to accomplish this, which is now supported by m-Painter, is to use an inline style as follows:

<td style="text- align: ${row. CALCULA001}">${row.FLD1}</td>

m-Painter has now been enhanced to allow field substitutions with any style attribute. A full list of properties and valid values for each can be found here: https://www.w3.org/TR/CSS21/propidx.html.

Conditionally Set a Color

Suppose I have a report that displays various orders. In this report I want to highlight the orders in which my customers ordered a quantity of 20 or more of a given product. This is a situation where you can use a field substitution within an HTML inline style.

  1. Create a conditional calculation that will set the calc equal to the word ‘yellow’ if the quantity ordered is greater than or equal to 20.
  2. Compile the application.
  3. In m-Painter open the HTML source and find the field substitution for the field you wish to highlight.
  4. Add an inline style to the <td> tag associated with this field that sets the cell’s background color equal to the calculation.

The resulting output is below:

Updated on June 20, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support