setValrep()
Set the ValRep for a field in the current occurrence.
FieldObject.setValrep(
ValRep)
Arguments
ValRep—new ValRep of the field instance, as a JavaScript object or an array.
For example, in JavaScript Object Notation (JSON), an object is represented as:
{ "1" : "paperback", "2" : "hardcover", "3" : "e-book" }
An array is represented as:
[ ["1", "paperback"], ["2", "hardcover"], ["3", "e-book"] ]
Note: The order in which items are displayed may vary when a JavaScript object is specified, depending on the browser. To ensure that the order is kept, use an array as parameter, or use setValrepArray.
Description
The initial values of a DSP field's ValRep list can be set in the widget properties dialog, or they can be set in ProcScript using $fieldvalrep.
The setValrep and setValRepArray functions set the ValRep list for the specified field in the current occurrence. Only this single instance of the specified field is affected, and the ValRep list remains in effect even when the occurrence is no longer the current occurrence.
Once the DSP is loaded, the ValRep list of the field instance can be dynamically changed in the browser using the setValrep or setValRepArray API functions.
Range ValReps
For numeric fields, it is possible to specifying a Uniface range value in the format Min:Max for both values of a JavaScript range specification. For example:
field.setValrep( {"-1:5" : "-1:5" });
For non-numeric fields, range Valreps are not supported, and specifying a range will result in a warning in the browser console.
If a range ValRep is defined for a field with a dropdown or radio group widget, a formatting error will be generated, and the definition ValRep (if defined) will be used. If no valid ValRep was defined, an empty ValRep will be set instead, and the range ValRep will be discarded.
Multi-range or nested range ValReps are not supported in DSPs.