Wraps the popular Select2 library.
Supports the DotVVM data-binding using the DataSource
property.
This control requires jQuery to be registered as a DotVVM resource with resource name: jquery
.
You can bind the control to a collection of strings. The SelectedValues
property retrieves a list of selected items.
<dc:Select2 DataSource="{value: CityNames}" SelectedValues="{value: SelectedCityNames}" />
Similar to the built-in ComboBox
control, you can specify the DataMember
and ValueMember
properties and bind the control to a collection of objects - the DisplayMember
specifies the property of the object
which is displayed, and the ValueMember
specified the property of the object which will be used in the SelectedValues
collection.
<dc:Select2 DataSource="{value: Cities}" SelectedValues="{value: SelectedCityIds}" DisplayMember="Name" ValueMember="Id" />
The usage is exactly the same as built-in ComboBox
control. The rendered select can viewed in the Select2 Docs.
<dc:Select2Single DataSource="{value: Cities}" SelectedValue="{value: SelectedCityId}" DisplayMember="Name" ValueMember="Id" Placeholder="Example Placeholder" AllowClear="true" />