Implement a Custom Expression Property
Expressions allow survey creators to manage data flow and visual elements within a survey dynamically. Most survey elements have built-in expression properties (visibleIf
, enableIf
, setValueExpression
, etc.). This demo shows how to implement a custom expression property. This property controls the visibility of the table header in a Single-Select Matrix question.
To implement a custom expression property, follow the steps below:
Add a custom property to a desired class.
CallSerializer
'saddProperty
method, passing a class name and a JSON object with property settings.Specify the property's
name
andtype
.
Use the"condition"
type for Boolean expressions or the"expression"
type for other expressions.Specify the
onExecuteExpression
function.
This function will be called each time a specified expression is evaluated. This function should assign the evaluation result to one of the class instance properties. For example, in this demo, the result is assigned to theshowHeader
property of a Single-Select Matrix.
Refer to the code listing for a code example.