|
Purpose Adding a tooltip with dynamically generated content |
| In HTML the "title" attribute of an element specifies a tooltip text that is shown when the mouse moves over the element. The S10 Framework automatically generates a tooltip when the content cannot be fully shown due to a limited element width or container width. Example: ![]() HTML
In some cases, a tooltip that displays additional information can be helpful to the user. Example: ![]() Solution
1. Add a class attribute for the dynamic tooltip text in your ABAP program. For example, define "systemstatus_tooltip" in addition to the "systemstatus" attribute:
2.
Fill the variable "systemstatus_tooltip" in a "build" method, either in a separate method or, if it fits well because of similar accesses, in the "build" method for "systemstatus":ABAP
To display our tooltip in multiple lines as shown above, we separate the values with a line break.3. In HTML, we insert the "systemstatus_tooltip" variable as a "hidden" element after the "systemstatus" element. Using an "onchange" JavaScript function, we populate the "title" attribute of the preceding "systemstatus" element with the value of the "systemstatus_tooltip" variable: HTML
Dynamic tooltips in table cellsDynamic tooltips can also be used in table cells. Example: ![]() The implementation in ABAP is identical, but note that the tooltip variable and the "build" method must now be defined in the class corresponding to the table row. In HTML, the implementation is slightly different because the S10 Framework does not call an "onchange" method for individual table cells when the table is displayed. Instead, we can define an "onchange" method for the entire table, in which we step through all the tooltip elements of the table: HTML
JavaScript
|
|
Components |