Skip to main content

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.

public class Select : 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​

Instance member 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;

Instance member Select(options)​

Constructs a new instance of the Select class.

NameTypeDescription
optionsObjectInitial 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​

Instance member 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();
}

Instance member 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;

Instance member 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;

Instance member 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();

Instance member OnWidgetEvent(e)​

Processes the events received from the MobiScroll select and raises the WidgetEvent event.

ParameterTypeDescription
eWidgetEventArgsA 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.");
}
}

Instance member 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();
}

Instance member SetTempVal(value)​

Sets the temporary value that's selected on the picker.

ParameterTypeDescription
valueObjectThe 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");

Instance member SetVal(value)​

Sets the picker value and also writes it to the input.

ParameterTypeDescription
valueObjectThe 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​

Instance member Cancelled​

EventHandler<WidgetEventArgs> Triggered when cancel is pressed.

Instance member Changed​

EventHandler<WidgetEventArgs> Triggered when the value is changed.

Instance member Closed​

EventHandler<WidgetEventArgs> Triggered when the component is closed.

Instance member Filtered​

EventHandler<WidgetEventArgs> Gets fired when the filter input gets updated. Filtering can be turned on with the filter option.

Instance member Opened​

EventHandler<WidgetEventArgs> Triggered when the component is opened.

Instance member TempChanged​

EventHandler<WidgetEventArgs> Triggered when the temporary value is changed.

Implements​