Using structured tags
A common problem using a widget that use many tags is the need to create instances of the widget by giving only the tag name of the structure that contains all the tags instead to configure each single tag.
For example, think about the below widget. It use four tags, the room name, temperature, humidity and pressure. If we want use two instances of this widget for two different rooms we have to configure eight tags, four tags for each room.
By using a Parameter property, is possible to set all the data links of the widget by giving only the name of the structure.
A “Parameter” field can be added inside the custom widget using the "Add Parameter" icon:
To configure the data links of the custom widget the keyword ${RoomID} can be used to reference at the structure instance
Type filter
Typically, value of the parameter will be an element of a structured tag. Using the “Type filter” parameter, the “Select datatype text” will list filtered tags.
The “Select datatype text” will return a string while the “Attach to” will return a datalink to a tag that will contains the string to use.
getParameter
From JavaScript you can read the parameters' value using the getParameter()
object getParameter(paramID)
Example:
var myWidget = page.getWidget("myWidget");
function BtnStd3_btn_onMouseClick(me, eventInfo)
{
alert("Room is: " + myWidget.getParameter("RoomID"));
}
You can also use getProperty(), but getParameter() is more efficient to read custom widget parameters