Home Reference Source
import StringSelector from './gui/data-items/StringSelector.jsx'
public class | source

StringSelector

Extends:

gui/data-items/DataItemWithValue.js~DataItemWithValue → StringSelector

The purpose of a StringSelector is to store a string value given a fixed selection of choices. It will write to your tool's XML configuration the text of the "value" of the chosen option. It works with an "optionList" property which is an array of objects with "value" and "label" properties to provide user displayable text for each choice, independent of the value which will be stored in the tool's XML configuration. The default value is a blank string.

Constructor Summary

Public Constructor
public

constructor(dataName: string, dataItemProps: object)

Constructor

Member Summary

Public Members
public

doesOptionExist(optionValue: *): boolean: *

Function that returns true if an option exists in the data item's current optionList with the given value. Does not search the optionList based on label, must match the value property of an option.

public

getOptionList: array: *

Function that returns the current list of allowable value options, with displayable labels for the data item.

public

setOptionList(optionList: array): *

Function that changes the option list for the data item.

public

setOptionListFromStrings(stringArray: array): *

Function that sets the current list of allowable value options, using the string array given as label and value for each option.

Public Constructors

public constructor(dataName: string, dataItemProps: object) source

Constructor

Params:

NameTypeAttributeDescription
dataName string

The name of the data item.

dataItemProps object
  • optional

An object of properties such as hidden, disabled, suppressed etc.

dataItemProps.optionList array
  • optional
  • default: []

A list of strings or a list of objects where each object is in the form {value: 'val', label: 'label'}.

Public Members

public doesOptionExist(optionValue: *): boolean: * source

Function that returns true if an option exists in the data item's current optionList with the given value. Does not search the optionList based on label, must match the value property of an option.

Return:

boolean

If the option matching the specified value exists in the option list.

public getOptionList: array: * source

Function that returns the current list of allowable value options, with displayable labels for the data item.

Return:

array

The option list.

public setOptionList(optionList: array): * source

Function that changes the option list for the data item.

public setOptionListFromStrings(stringArray: array): * source

Function that sets the current list of allowable value options, using the string array given as label and value for each option. Do not use if you wish to persist something different from what you wish to display in UI.