Class SelectListView
public sealed class SelectListView : AbstractView
Inherited Members
Namespace: HomeSeer.Jui.Views
Assembly: PluginSdk.dll
A selection list allows a user to pick a value from a predefined collection.
Constructors
View SourceSelectListView(String, String, List<String>, ESelectListType, Int32)
Create a new instance of a select list with the default, drop down style, an ID, Name, and the specified list of options
Declaration
[JsonConstructor]
public SelectListView(string id, string name, List<string> options, ESelectListType style = ESelectListType.DropDown, int selection = -1)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The unique ID for this View |
System.String | name | The name of the view |
System.Collections.Generic.List<System.String> | options | The list of options |
ESelectListType | style | The display style of the select list. DEFAULT: drop down |
System.Int32 | selection | The index of the currently selected option in the list. DEFAULT: 0 |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if select list is create with an invalid list of options |
System.ArgumentOutOfRangeException | Thrown if select list is created with an invalid index for the currently selected option |
SelectListView(String, String, List<String>, List<String>, ESelectListType, Int32)
Create a new instance of a select list with the default, drop down style, an ID, Name, and the specified list of options and keys
Declaration
public SelectListView(string id, string name, List<string> options, List<string> optionKeys, ESelectListType style = ESelectListType.DropDown, int selection = -1)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The unique ID for this View |
System.String | name | The name of the view |
System.Collections.Generic.List<System.String> | options | The list of options |
System.Collections.Generic.List<System.String> | optionKeys | The list of keys corresponding to the list of options |
ESelectListType | style | The display style of the select list. DEFAULT: drop down |
System.Int32 | selection | The index of the currently selected option in the list. DEFAULT: 0 |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if select list is create with an invalid list of options |
System.ArgumentOutOfRangeException | Thrown if select list is created with an invalid index for the currently selected option |
Fields
View Source_selection
Declaration
int _selection
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
View SourceDefaultSelectionText
The text displayed when Selection equals -1. If this property is null or empty, "Select an option" is displayed.
Declaration
[JsonProperty("default_selection_text")]
public string DefaultSelectionText { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
View SourceOptionKeys
A list of keys that corresponds to the Options list.
For internal use by a plugin. This is not displayed or used in any fashion otherwise.
Declaration
[JsonProperty("keys")]
public List<string> OptionKeys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
Options
A list of options that the user can select from
Declaration
[JsonProperty("options")]
public List<string> Options { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
Selection
The index of the currently selected option in the list. This is the value for this view.
Declaration
[JsonProperty("selection")]
public int Selection { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Set this to -1 to display a default "Select an option" text
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when the selection is set to an index that does not work for the current Options |
Style
The display style for the list of options
Declaration
[JsonProperty("style")]
public ESelectListType Style { get; set; }
Property Value
Type | Description |
---|---|
ESelectListType |
UseOptionKeyAsSelectionValue
When this property is true, GetStringValue() returns the selected option key instead of the selected option index, and UpdateValue(String) expects an option key as parameter instead of an option index.
Declaration
[JsonProperty("use_option_key_as_selection_value")]
public bool UseOptionKeyAsSelectionValue { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
View SourceGetSelectedOption()
Get the currently selected option text.
Declaration
public string GetSelectedOption()
Returns
Type | Description |
---|---|
System.String | The text of the option at the index specified by Selection. |
GetSelectedOptionKey()
Get the currently selected option key
Declaration
public string GetSelectedOptionKey()
Returns
Type | Description |
---|---|
System.String | The key of the option at the index specified by Selection. |
GetStringValue()
Get the value associated with this view as a string if there is one.
Declaration
public override string GetStringValue()
Returns
Type | Description |
---|---|
System.String | The value stored in this view as a string or NULL if there is no value stored. |
Overrides
Remarks
Returns the selected option key if UseOptionKeyAsSelectionValue is true, else returns the selected index as a string
ToHtml(Int32)
Get a string representation of this view converted into HTML
Declaration
public override string ToHtml(int indent = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | indent |
Returns
Type | Description |
---|---|
System.String | An HTML representation of the view as a string |
Overrides
View SourceUpdate(AbstractView)
Update the view to the new state. This will change the selected option
Declaration
public override void Update(AbstractView newViewState)
Parameters
Type | Name | Description |
---|---|---|
AbstractView | newViewState | The new state of the view being updated. This view's ID and Type must match the calling view exactly |
Overrides
Exceptions
Type | Condition |
---|---|
ViewTypeMismatchException | Thrown when the new view's class doesn't match the calling view |
UpdateValue(String)
Update the value of the view
Declaration
public override void UpdateValue(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The new value |
Overrides
Exceptions
Type | Condition |
---|---|
System.FormatException | Thrown when the value is not in the correct format |