Options
The options API of Multiple Select.
The Options are defined in jQuery.fn.multipleSelect.defaults.
name
Attribute:
nameType: String
Detail: The name of the select element.
Default:
''Example: Submit Select
placeholder
Attribute:
placeholderType: String
Detail: A placeholder value can be defined and will be displayed until you select an item.
Default:
''Example: The Placeholder
classes
Attribute:
data-classesType: String
Detail: The class name of select.
Default:
''Example: The Classes
classPrefix
Attribute:
data-class-prefixType: String
Detail: The class prefix of select.
Default:
''Example: The Classes
classInput
Attribute:
data-class-inputType: String
Detail: The class of input radio/checkbox.
Default:
''Example: The Themes
data
Attribute:
-Type: Array
Detail: The data to be loaded.
The optgroup object contains these parameters:
type:'optgroup'.label: the label of optgroup.visible: where to display this optgroup.selected: where to select this optgroup.disabled: where to disable this optgroup.children: the options of this optgroup.
Examples:
<optgroup label="group1"> <option value="1">option 1</option> </optgroup>[ { type: 'optgroup', label: 'Group 1', children: [ { text: 'Option 1', value: 1 } ] } ]The option object contains these parameters:
text: the text of option.value: the value of option.visible: where to display this option.selected: where to select this option.disabled: where to disable this option.classes: the class of the option.title: the title of the option.divider: display this option as a divider.
Examples:
<option value="1">Option 1</option> <option data-divider="true"></option> <option value="2">Option 2</option>[ { text: 'Option 1', value: 1 }, { divider: true }, { text: 'Option 2', value: 2 } ]Or Object:
{ 1: 'Option 1' }Or String/Number Array:
['option1'] [1]Default: []
Example: The Data.
locale
Attribute:
data-localeType:
StringDetail:
Sets the locale to use (i.e.
'zh-CN'). Locale files must be pre-loaded. Allows for fallback locales, if loaded, in the following order:- First tries for the locale as specified,
- Then tries the locale with '_' translated to '-' and the region code upper cased,
- Then tries the short locale code (i.e.
'zh'instead of'zh-CN'), - Finally, we will use the last locale file loaded (or the default locale if no locales are loaded).
If left
undefinedor an empty string, use the last locale loaded (or'en-US'if no locale files loaded).Default:
undefinedExample: The Locale
selectAll
Attribute:
data-select-allType: Boolean
Detail: Show selects all checkbox.
Default:
trueExample: Hide Select All
single
Attribute:
data-singleType: Boolean
Detail: Allows you to select only one option, if the select has not multiple attribute, this option will auto set to
true.Default:
undefinedExample: Single Row
singleRadio
Attribute:
data-single-radioType: Boolean
Detail: Allows you to show the radio input when
singleis set totrue.Default:
falseExample: Single Radio
multiple
Attribute:
data-multipleType: Boolean
Detail: Show multiple items in a row.
Default:
falseExample: Multiple Items
hideOptgroupCheckboxes
Attribute:
data-hide-optgroup-checkboxesType: Boolean
Detail: Hide the optgroup checkboxes.
Default:
falseExample: Hide Optgroup Check
multipleWidth
Attribute:
data-multiple-widthType: Number
Detail: Show the width of multiple items.
Default:
80Example:
- Multiple Items
width
Attribute:
data-widthType: undefined
Detail: Define the width property of the select, support a percentage setting.
Default:
undefinedExample: Custom Dropdown Width
maxWidth
Attribute:
data-max-widthType: Number | String
Detail: Define the maximum width of the select when
width: 'auto'is set. If the auto-calculated width exceeds this value, the width will be capped atmaxWidth.Default:
undefinedExample: Custom Dropdown Width
size
Attribute:
data-sizeType: String
Detail: The size of select.
Default:
''Example: The Classes
dropWidth
Attribute:
data-drop-widthType: undefined
Detail: Define the dropdown width.
Default:
undefinedExample: Custom Dropdown Width
maxHeight
Attribute:
data-max-heightType: Number
Detail: Define the maximum height property of the dropdown list.
Default:
250Example: Max Height
maxHeightUnit
Attribute:
data-max-height-unitType: String
Detail: Define the unit of the
maxHeightoption, can only be 'px' or 'row'.Default:
pxExample: Max Height Unit
position
Attribute:
data-positionType: String
Detail: Defines the position of the select dropdown, can only be 'bottom' or 'top'.
Default:
bottomExample: The Position
displayValues
Attribute:
data-display-valuesType: Boolean
Detail: Display selected values instead of text.
Default:
falseExample: Display Values
displayTitle
Attribute:
data-display-titleType: Boolean
Detail: Display the
titleof selected text.Default:
falseExample: Display Title
displayDelimiter
Attribute:
data-display-delimiterType: String
Detail: Customize the display delimiter.
Default:
,Example: Display Delimiter
minimumCountSelected
Attribute:
data-minimum-count-selectedType: Number
Detail:
formatCountSelectedwill be shown only if more thanminimumCountSelecteditems were selected.Default:
3Example: Minimum Count Selected
ellipsis
Attribute:
data-ellipsisType: Boolean
Detail: Add
'...'after selected options ifminimumCountSelectedis set. OverridesformatCountSelectedoption.Default:
falseExample: The Ellipsis
isOpen
Attribute:
data-is-openType: Boolean
Detail: Open the select dropdown by default.
Default:
falseExample: Is Open
keepOpen
Attribute:
data-keep-openType: Boolean
Detail: Keep the select dropdown always open.
Default:
falseExample: Keep Open
openOnHover
Attribute:
data-open-on-hoverType: Boolean
Detail: Open the select dropdown by hovering instead of clicking.
Default:
falseExample: Open On Hover
container
Attribute:
data-containerType: object
Detail: Define a custom container to solve the cut-off problem. For example, the parent node is
overflow: hidden.Default:
nullExample: The Container
filter
Attribute:
data-filterType: Boolean
Detail: Show a search field to search through checkbox items.
Default:
falseExample: The Filter
filterGroup
Attribute:
data-groupType: Boolean
Detail: Filter optgroups only and not options.
Default:
falseExample: Filter Only Optgroup
filterOptions
Attribute:
data-filter-optionsType: Boolean
Detail: Show filter options (All, Selected, Unselected) in the filter. This option only works with multiple select. Note: This option requires
filterto be enabled (filter: true).Default:
falseExample: Filter Options
filterOnly
Attribute:
data-filter-onlyType: Boolean
Detail: Show a "filter only" button on each option in multiple select mode. When clicked, all options are unchecked and only the clicked option is selected. Only works with multiple select (not single select).
Default:
falseExample: Filter Only
filterPlaceholder
Attribute:
data-filter-placeholderType: String
Detail: Set the filter placeholder.
Default: ``
Example: Filter Placeholder
filterAcceptOnEnter
Attribute:
data-filter-accept-on-enterType: Boolean
Detail: Speed up keyboard use. Enter filter text and then hit
enterorspace. It will auto-clickselect alland close the dropdown.Default:
falseExample: Filter Accept On Enter
filterByDataLength
Attribute:
data-filter-by-data-lengthType: Number
Detail: Auto enable filter when the data(options) length is more than the set number.
Default:
undefinedExample: Filter By Data Length
filterSelectAll
Attribute:
data-filter-select-allType: Boolean
Detail: Show select all checkbox in the filter.
Default:
undefinedExample: Filter Select All
customFilter
Attribute:
-Type: function
Detail: The custom filter function returns a boolean to filter or not, containing parameter:
{ text, label, search }.Default:
{ return (label || text).includes(search) }Example: Custom Filter
showClear
Attribute:
data-show-clearType: undefined
Detail: Show the clear icon to uncheck all selected items.
Default:
falseExample: Show Clear
animate
Attribute:
data-animateType: undefined
Detail: Define the animation of opening or closing the dropdown. It can be
undefined,'fade'and'slide'.Default:
undefinedExample: The Animate
styler
Attribute:
-Type: function
Detail: The item styler function returns a style string to custom the item style, containing the parameter:
row. (updated 1.4.1)Default:
{ return false }Example: The Styler
textTemplate
Attribute:
-Type: function
Detail: The item textTemplate function returns a string to customize the item text, containing the parameter
$elm.Default:
{ return $elm[0].innerHTML }Example: Text Template
labelTemplate
Attribute:
-Type: function
Detail: The item labelTemplate function, return string to custom the optgroup label, contains parameter:
$elm.Default:
{ return $elm[0].getAttribute('label') }Example: Label Template