Select
Namespace: Wisej.Web.Ext.MobiScroll
Assembly: Wisej.Web.Ext.MobiScroll (4.1.0.0)
The Mobiscroll Select component lets you pick a single or multiple values from a list of options.
- C#
- VB.NET
public class Select : MSComponentBase
Public Class [Select]
Inherits MSComponentBase
The component is created in the browser on the first child control of the control assigned to Control, using the options that are set at that time.
Constructors
Select()
Constructs a new instance of the Select class.
This constructor leaves Options set to null: assign a new options object before setting Control.
Example:
The following example creates a select, assigns the list of cities and attaches it to a panel that contains the target control.
var select = new Select();
select.Options = new
{
data = new[] { "Atlanta", "Berlin", "London", "Paris" },
display = "anchored"
};
select.Control = this.panelCity;
Select(options)
Constructs a new instance of the Select class.
| Name | Type | Description |
|---|---|---|
| options | Object | Initial set of options. |
Example:
The following example creates a filterable multiple select with separate texts and values, and shows the selection in a label.
var select = new Select(new
{
data = new[]
{
new { text = "Atlanta", value = "ATL" },
new { text = "Berlin", value = "BER" },
new { text = "London", value = "LON" }
},
selectMultiple = true,
filter = true
});
select.WidgetEvent += (s, e) =>
{
if (e.Type == "onChange")
this.labelCities.Text = e.Data.valueText;
};
select.Control = this.panelCities;
Methods
Close()
Closes the component.
Example:
The following example closes the picker when the user clicks a button outside of it.
private void buttonDone_Click(object sender, EventArgs e)
{
this.select1.Close();
}
GetTempValAsync()
Returns the temporary value that's selected on the picker.
Returns: Task<Object>. A task that returns the temporary value: a single value, or an array of values when the MobiScroll selectMultiple option is enabled.
The temporary value is the selection shown in the open picker that the user has not confirmed yet.
Example:
The following example previews the city highlighted in the open picker before the user confirms it.
var city = await this.select1.GetTempValAsync();
this.labelPreview.Text = city == null ? "" : (string)city;
GetValAsync()
Returns the selected value of the picker, that has been set to the input as well.
Returns: Task<Object>. A task that returns the selected value: a single value, or an array of values when the MobiScroll selectMultiple option is enabled.
Example:
The following example saves the selected city.
var city = await this.select1.GetValAsync();
if (city != null)
this.customer.City = (string)city;
IsVisibleAsync()
Returns a boolean indicating whether the component is visible or not.
Returns: Task<Boolean>. A task that returns true when the picker is open, otherwise false.
Example:
The following example toggles the picker.
if (await this.select1.IsVisibleAsync())
this.select1.Close();
else
this.select1.Open();
OnWidgetEvent(e)
Processes the events received from the MobiScroll select and raises the WidgetEvent event.
| Parameter | Type | Description |
|---|---|---|
| e | WidgetEventArgs | A WidgetEventArgs with the name of the MobiScroll event and its data. |
Example:
The following example defines a select that notifies the user when the selection is cancelled.
public class CitySelect : Select
{
public override void OnWidgetEvent(WidgetEventArgs e)
{
base.OnWidgetEvent(e);
if (e.Type == "onCancel")
AlertBox.Show("No city has been selected.");
}
}
Open()
Opens the component.
Example:
The following example opens the picker from a button.
private void buttonChooseCity_Click(object sender, EventArgs e)
{
this.select1.Open();
}
SetTempVal(value)
Sets the temporary value that's selected on the picker.
| Parameter | Type | Description |
|---|---|---|
| value | Object | The value to select: a single value, or an array of values when the MobiScroll selectMultiple option is enabled. |
The temporary value changes the selection shown in the open picker without writing it to the input; the user can still confirm or cancel it.
Example:
The following example opens the picker with a suggested city highlighted.
this.select1.Open();
this.select1.SetTempVal("BER");
SetVal(value)
Sets the picker value and also writes it to the input.
| Parameter | Type | Description |
|---|---|---|
| value | Object | The value to select: a single value, or an array of values when the MobiScroll selectMultiple option is enabled. |
Example:
The following example selects two cities in a select with the MobiScroll selectMultiple option enabled.
this.select1.SetVal(new[] { "ATL", "LON" });
Events
Cancelled
EventHandler<WidgetEventArgs> Triggered when cancel is pressed.
Changed
EventHandler<WidgetEventArgs> Triggered when the value is changed.
Closed
EventHandler<WidgetEventArgs> Triggered when the component is closed.
Filtered
EventHandler<WidgetEventArgs> Gets fired when the filter input gets updated. Filtering can be turned on with the filter option.
Opened
EventHandler<WidgetEventArgs> Triggered when the component is opened.
TempChanged
EventHandler<WidgetEventArgs> Triggered when the temporary value is changed.
Implements
| Name | Description |
|---|---|
| IUserData | |
| IWisejComponent | |
| IWisejSerializable |