Skip to content

CodeCoupler UI DataSource Mixin "Extended Fields"

Part of the CodeCoupler UI Pro package.

A DataSource Mixin providing an extended model definition. In addition to the basic field configuration properties type, defaultValue etc. the following properties can be used:

constant: Any

The given value will always be set for this field. Using this property the properties parse and defaultValue cannot be used.

optionalFrom: String

Like from, but it preprocess the response and set the value of the field to null if not defined. If you use just from the datasource would throw an error if this target field do not exist in the response. The reference in sub-objects is supported (string can be a.b.field for example). If you are using schema.data as a function you must know that these fields will be created after executing your function.

calculated: Function(value,dataItem,args) || [ function, args ]

The function receives (in contrast to parse) additionally the whole item received from the server. You can calculate on that base and return any value the field should get. The function will receive the value of the field if this exists. Otherwise value will be "undefined". You can set an array with first argument the function and as second argument any value that will be passed to the function as third parameter. Do not use this with from or optionalFrom as the value will be set from these fields. If you are using schema.data as a function you must know that your function will be called first.