@@ -19,9 +19,7 @@ The following example shows how to instantiate the Multiselect widget:
19
19
$ (" #multiselect" ).multiselect2 ({});
20
20
```
21
21
22
- Where:
23
-
24
- - ` #multiselect ` is the selector of the select element for which Multiselect is initialized.
22
+ where ` #multiselect ` is the selector of the select element for which Multiselect is initialized.
25
23
26
24
The following example shows a PHTML file using the script:
27
25
@@ -42,31 +40,40 @@ The following example shows a PHTML file using the script:
42
40
43
41
The RedirectUrl widget has the following options:
44
42
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 )
43
+ - [ containerClass] ( #containerclass )
44
+ - [ currentPage] ( #currentpage )
45
+ - [ lastAppendValue] ( #lastappendvalue )
46
+ - [ mselectCheckedClass] ( #mselectcheckedclass )
47
+ - [ mselectContainer] ( #mselectcontainer )
48
+ - [ mselectItemsWrapperClass] ( #mselectitemswrapperclass )
49
+ - [ nextPageUrl] ( #nextpageurl )
50
+ - [ searchInputClass] ( #searchinputclass )
51
+ - [ selectedItemsCountClass] ( #selecteditemscountclass )
52
+ - [ updateDelay] ( #updatedelay )
54
53
55
- ### ` mselectContainer `
54
+ ### ` containerClass `
56
55
57
- Multiselect container selector.
56
+ The class which is attached to the container with [ multi-select container selector] ( #mselectcontainer ) .
58
57
59
58
** Type** : String
60
59
61
- ** Default value** : ` 'section.mselect-list ' `
60
+ ** Default value** : ` 'paginated ' `
62
61
63
- ### ` mselectItemsWrapperClass `
62
+ ### ` currentPage `
64
63
65
- Multiselect items wrapper class .
64
+ Current page of multi-select items .
66
65
67
- ** Type** : String
66
+ ** Type** : Integer
68
67
69
- ** Default value** : ` 'mselect-items-wrapper' `
68
+ ** Default value** : ` 1 `
69
+
70
+ ### ` lastAppendValue `
71
+
72
+ The value of the last added multi-select item.
73
+
74
+ ** Type** : Integer, String
75
+
76
+ ** Default value** : ` 0 `
70
77
71
78
### ` mselectCheckedClass `
72
79
@@ -76,13 +83,48 @@ The class which is attached to a checked multi-select item.
76
83
77
84
** Default value** : ` 'mselect-checked' `
78
85
79
- ### ` containerClass `
86
+ ### ` mselectContainer `
80
87
81
- The class which is attached to the container with [ multi-select container selector] ( #mselectcontainer ) .
88
+ Multiselect container selector.
82
89
83
90
** Type** : String
84
91
85
- ** Default value** : ` 'paginated' `
92
+ ** Default value** : ` 'section.mselect-list' `
93
+
94
+ ### ` mselectItemsWrapperClass `
95
+
96
+ Multiselect items wrapper class.
97
+
98
+ ** Type** : String
99
+
100
+ ** Default value** : ` 'mselect-items-wrapper' `
101
+
102
+ ### ` nextPageUrl `
103
+
104
+ The url of the controller or API which returns the JSON response.
105
+
106
+ ``` json
107
+ {
108
+ "success" : true ,
109
+ "errorMessage" : " " ,
110
+ "result" : [
111
+ {
112
+ "value" : " 1" ,
113
+ "label" : " Multi-select item label #1"
114
+ },
115
+ {
116
+ "value" : " 2" ,
117
+ "label" : " Multi-select item label #2"
118
+ }
119
+ ]
120
+ }
121
+ ```
122
+
123
+ An example of the controller: [ ` <Magento_Tax_module_dir>/Controller/Adminhtml/Rule/AjaxLoadRates.php ` ] [ ]
124
+
125
+ ** Type** : String
126
+
127
+ ** Default value** : ` undefined `
86
128
87
129
### ` searchInputClass `
88
130
@@ -100,29 +142,92 @@ Class of the selected items counter.
100
142
101
143
** Default value** : ` 'admin__action-multiselect-search' `
102
144
103
- ### ` currentPage `
145
+ ### ` updateDelay `
104
146
105
- Current page of multi-select items .
147
+ The search field update delay .
106
148
107
- ** Type** : Integer
149
+ ** Type** : Integer, String
108
150
109
- ** Default value** : ` 1 `
151
+ ** Default value** : ` 0 `
110
152
111
- ### ` lastAppendValue `
153
+ ## Methods
112
154
113
- The value of the last added multi-select item.
155
+ The Multiselect methods are the following:
114
156
115
- ** Type** : Integer, String
157
+ - [ appendOptions()] ( #appendoptions )
158
+ - [ clearMultiselectOptions()] ( #clearmultiselectoptions )
159
+ - [ getCurrentPage()] ( #getcurrentpage )
160
+ - [ getSearchCriteria()] ( #getsearchcriteria )
161
+ - [ isOptionsLoaded()] ( #isoptionsloaded )
162
+ - [ loadOptions()] ( #loadoptions )
163
+ - [ setCurrentPage()] ( #setcurrentpage )
116
164
117
- ** Default value ** : ` 0 `
165
+ ### ` appendOptions `
118
166
119
- ### ` updateDelay `
167
+ The method appends multi-select items to the multi-select.
120
168
121
- The search field update delay.
169
+ Code example:
122
170
123
- ** Type** : Integer, String
171
+ ``` javascript
172
+ $ (' #multiselect' ).multiselect2 (' appendOptions' , [{" value" : " 1" , " label" : " Label #1" }, {" value" : " 2" , " label" : " Label #2" }]);
173
+ ```
124
174
125
- ** Default value** : ` 0 `
175
+ ### ` clearMultiselectOptions `
176
+
177
+ The method removes all multi-select items.
178
+
179
+ Code example:
180
+
181
+ ``` javascript
182
+ $ (' #multiselect' ).multiselect2 (' clearMultiselectOptions' );
183
+ ```
184
+
185
+ ### ` getCurrentPage `
186
+
187
+ The method returns the number of the current page.
188
+
189
+ ``` javascript
190
+ $ (' #multiselect' ).multiselect2 (' getCurrentPage' );
191
+ ```
192
+
193
+ ### ` getSearchCriteria `
194
+
195
+ The method returns the trimmed value of the search input.
196
+
197
+ Code example:
198
+
199
+ ``` javascript
200
+ $ (' #multiselect' ).multiselect2 (' getSearchCriteria' );
201
+ ```
202
+
203
+ ### ` isOptionsLoaded `
204
+
205
+ The method checks if all multi-select items are already loaded.
206
+
207
+ ``` javascript
208
+ $ (' #multiselect' ).multiselect2 (' isOptionsLoaded' , [{" value" : " 2" , " label" : " Label #2" }]);
209
+ ```
210
+
211
+ This method returns ` true ` if multiple selection items are loaded, and it returns ` false ` if they are not loaded.
212
+
213
+ ### ` loadOptions `
214
+
215
+ The method loads the next page with multi-select items from [ nextPageUrl] ( #nextpageurl ) according to the [ search criteria] ( #getsearchcriteria ) .
216
+ The multi-select items from the Ajax response are appended to the multi-select.
217
+
218
+ Code example:
219
+
220
+ ``` javascript
221
+ $ (' #multiselect' ).multiselect2 (' loadOptions' );
222
+ ```
223
+
224
+ ### ` setCurrentPage `
225
+
226
+ The method configures the current page number.
227
+
228
+ ``` javascript
229
+ $ (' #multiselect' ).multiselect2 (' setCurrentPage' , 2 );
230
+ ```
126
231
127
232
## Code sample
128
233
@@ -156,3 +261,4 @@ You can now search for an option in the search bar and the **Add new value** but
156
261
<!-- Link Definitions -->
157
262
[ lib/web/mage/multiselect.js] : {{ site.mage2bloburl }}/{{ page.guide_version }}/lib/web/mage/multiselect.js
158
263
[ Initialize JavaScript ] : {{page.baseurl}}/javascript-dev-guide/javascript/js_init.html
264
+ [ ` <Magento_Tax_module_dir>/Controller/Adminhtml/Rule/AjaxLoadRates.php ` ] : {{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Tax/Controller/Adminhtml/Rule/AjaxLoadRates.php
0 commit comments