PicklistAttribute
An Attribute for a picklist field. Also has all the methods available in Attribute.
Use form.attribute to get an instance of this class.
getOptions
attribute.getOptions(): PicklistOptionValue[];
interface PicklistOptionValue {
text: string;
value: number;
}
Returns the non-null picklist options for the attribute.
setAvailableOptions
attribute.setAvailableOptions(availableValues: (number|null)[], _opts?: SetAvailableOptionsSettings): void;
interface SetAvailableOptionsSettings {
/** If the current value is no longer valid, the field will be set to this value.
* If not specified, the first item listed in the availableValues array is used. */
defaultValue?: number | null;
}
Configures which options are available in the control. All options besides the listed available values will be removed.
addDependency
attribute.addDependency(parentAttribute: string, mapping: PicklistDependencyMappings): void;
interface PicklistDependencyMappings {
null?: (number | null)[];
[key: number]: (number | null)[];
}
Adds a parent/child picklist dependency so that the values available in this dropdown are based on the value of the parent attribute.
If this is an existing configuration using addDependency, the new mapping will replace it.
function formOnLoad_addDependencySample(e) {
const form = Hsl.form(e);
const childPicklist = form.attribute('hsl_childpicklist');
childPicklist.addDependency('hsl_parentpicklist', {
null: [null, 1],
1: [1, 2],
2: [1, 2],
3: [null, 3, 4],
4: [3, 4],
5: [5],
});
}
removeDependency
attribute.removeDependency(): void;
Removes the dependency configuration created by addDependency for the attribute and restores the options.