Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit e8168f4

Browse files
serhiyzhovnirjeff-matthews
authored andcommitted
Added the documentation for multiselect widget (#5207)
* Added the documentation for multiselect widget * Add multiselect widget link * Adjusted the multiselect widget documentation * Adjusted the documentation for multiselect widget * Remove trailing spaces * Fixed the updateDelay link
1 parent 7a3d0c4 commit e8168f4

File tree

5 files changed

+164
-0
lines changed

5 files changed

+164
-0
lines changed

_data/toc/javascript-developer-guide.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ pages:
8282
- label: Modal widget
8383
url: /javascript-dev-guide/widgets/widget_modal.html
8484

85+
- label: Multiselect widget
86+
url: /javascript-dev-guide/widgets/widget-multiselect.html
87+
8588
- label: Navigation widget
8689
url: /javascript-dev-guide/widgets/widget_navigation.html
8790

Loading

guides/v2.2/javascript-dev-guide/widgets/jquery-widgets-about.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This guide discusses the following widgets:
2020
- [Loader widget]
2121
- [Menu widget]
2222
- [Modal widget]
23+
- [Multiselect widget]
2324
- [Navigation widget]
2425
- [PasswordStrengthIndicator widget]
2526
- [PopupWindow widget]
@@ -50,6 +51,7 @@ Magento out of the box does not contain jQuery UI styles. Also, it is not recomm
5051
[Loader widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget_loader.html
5152
[Menu widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget_menu.html
5253
[Modal widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget_modal.html
54+
[Multiselect widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget-multiselect.html
5355
[Navigation widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget_navigation.html
5456
[PasswordStrengthIndicator widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget_password_strength_indicator.html
5557
[PopupWindow widget]: {{page.baseurl}}/javascript-dev-guide/widgets/widget-popup-window.html
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
group: javascript-developer-guide
3+
title: Multiselect widget
4+
contributor_name: Atwix
5+
contributor_link: https://www.atwix.com/
6+
---
7+
8+
This [widget](https://glossary.magento.com/widget/) enables multiple select capability in the search field to help users choose different options.
9+
10+
The Multiselect widget source is the [lib/web/mage/multiselect.js][] file.
11+
12+
## Initialize the Multiselect widget
13+
14+
For information about how to initialize a widget in a JS component or `.phtml` template, see the [Initialize JavaScript][] topic.
15+
16+
The following example shows how to instantiate the Multiselect widget:
17+
18+
```javascript
19+
$("#multiselect").multiselect2({});
20+
```
21+
22+
Where:
23+
24+
- `#multiselect` is the selector of the select element for which Multiselect is initialized.
25+
26+
Phtml template file examples using script:
27+
28+
```html
29+
<script>
30+
require([
31+
'jquery',
32+
'mage/multiselect'
33+
], function ($) {
34+
'use strict';
35+
36+
$("#multiselect").multiselect2({});
37+
});
38+
</script>
39+
```
40+
41+
## Options
42+
43+
The RedirectUrl widget has the following options:
44+
45+
- [mselectContainer](#mselectcontainer)
46+
- [mselectItemsWrapperClass](#mselectitemswrapperclass)
47+
- [mselectCheckedClass](#mselectcheckedclass)
48+
- [containerClass](#containerclass)
49+
- [searchInputClass](#searchinputclass)
50+
- [selectedItemsCountClass](#selecteditemscountclass)
51+
- [currentPage](#currentpage)
52+
- [lastAppendValue](#lastappendvalue)
53+
- [updateDelay](#updatedelay)
54+
55+
### `mselectContainer`
56+
57+
Multiselect container selector.
58+
59+
**Type**: String
60+
61+
**Default value**: `'section.mselect-list'`
62+
63+
### `mselectItemsWrapperClass`
64+
65+
Multiselect items wrapper class.
66+
67+
**Type**: String
68+
69+
**Default value**: `'mselect-items-wrapper'`
70+
71+
### `mselectCheckedClass`
72+
73+
The class which is attached to a checked multi-select item.
74+
75+
**Type**: String
76+
77+
**Default value**: `'mselect-checked'`
78+
79+
### `containerClass`
80+
81+
The class which is attached to the container with [multi-select container selector](#mselectcontainer).
82+
83+
**Type**: String
84+
85+
**Default value**: `'paginated'`
86+
87+
### `searchInputClass`
88+
89+
Class of the search input.
90+
91+
**Type**: String
92+
93+
**Default value**: `'admin__action-multiselect-search'`
94+
95+
### `selectedItemsCountClass`
96+
97+
Class of the selected items counter.
98+
99+
**Type**: String
100+
101+
**Default value**: `'admin__action-multiselect-search'`
102+
103+
### `currentPage`
104+
105+
Current page of multi-select items.
106+
107+
**Type**: Integer
108+
109+
**Default value**: `1`
110+
111+
### `lastAppendValue`
112+
113+
The value of the last added multi-select item.
114+
115+
**Type**: Integer, String
116+
117+
**Default value**: `0`
118+
119+
### `updateDelay`
120+
121+
The search field update delay.
122+
123+
**Type**: Integer, String
124+
125+
**Default value**: `0`
126+
127+
## Code sample
128+
129+
The following example shows the multiselect field with search bar and **Add new value** button.
130+
131+
```html
132+
<div class="select-example">
133+
<select id="multiselect" name="multiselect-field" multiple="multiple">
134+
<option value="1">Option 1</option>
135+
<option value="2">Option 2</option>
136+
<option value="3">Option 3</option>
137+
<option value="4">Option 4</option>
138+
<option value="5">Option 5</option>
139+
<option value="6">Option 6</option>
140+
</select>
141+
<script>
142+
require(['jquery', 'mage/multiselect'], function ($) {
143+
$('#multiselect').multiselect2({selectedValues: [2, 4]});
144+
});
145+
</script>
146+
</div>
147+
```
148+
149+
## Result
150+
151+
As a result, we see the multiselect field with search bar and **Add new value** button.
152+
You can now search for an option in the search bar and the **Add new value** button allows you to add a new option to the multiselect feature.
153+
154+
![Multiselect Widget Example]({{ site.baseurl }}/common/images/widget/multiselect-widget-result.png)
155+
156+
<!-- Link Definitions -->
157+
[lib/web/mage/multiselect.js]: {{ site.mage2bloburl }}/{{ page.guide_version }}/lib/web/mage/multiselect.js
158+
[Initialize JavaScript]: {{page.baseurl}}/javascript-dev-guide/javascript/js_init.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../v2.2/javascript-dev-guide/widgets/widget-multiselect.md

0 commit comments

Comments
 (0)