File tree Expand file tree Collapse file tree 3 files changed +67
-12
lines changed
docs/src/pages/components Expand file tree Collapse file tree 3 files changed +67
-12
lines changed Original file line number Diff line number Diff line change 303
303
<div class =" multiple" slot =" demo" >
304
304
<div class =" field-group" >
305
305
<md-input-container >
306
- <label for =" users" >Users</label >
306
+ <label for =" users" >Simple multiselect</label >
307
+ <md-select name =" option" id =" option" multiple v-model =" items" >
308
+ <md-option v-for =" option in options"
309
+ :key =" option"
310
+ :value =" option" >
311
+ {{ option.name }}
312
+ </md-option >
313
+ </md-select >
314
+ </md-input-container >
315
+ </div >
316
+
317
+ <div >Selected letters: {{ items }}</div >
318
+ <br />
319
+ <br />
320
+
321
+ <div class =" field-group" >
322
+ <md-input-container >
323
+ <label for =" users" >Multiselect with subheaders</label >
307
324
<md-select name =" users" id =" users" multiple v-model =" users" >
308
325
<md-subheader >Managers</md-subheader >
309
326
<md-option value =" jim_halpert" >Jim Halpert</md-option >
325
342
</md-select >
326
343
</md-input-container >
327
344
</div >
328
-
345
+
329
346
<div >Selected users: {{ users }}</div >
347
+
330
348
</div >
331
349
332
350
<div slot =" code" >
333
351
<code-block lang =" xml" >
352
+ < ; md-input-container> ;
353
+ < ; label for=" ; users=" ;> ; Simple multiselect< ; /label> ;
354
+ < ; md-select name=" ; option=" ; id=" ; option=" ; multiple v-model=" ; items=" ;> ;
355
+ < ; md-option v-for=" ; option in options=" ;
356
+ :key=" ; option=" ;
357
+ :value=" ; option=" ;> ;
358
+ { { option.name } }
359
+ < ; /md-option> ;
360
+ < ; md-select> ;
361
+ < ; /md-input-container> ;
362
+
363
+ < ; div> ; Selected letters: {{ items }}< ; /div> ;
364
+
365
+
334
366
< ; md-input-container> ;
335
367
< ; label for=" ; users" ;> ; Users< ; /label> ;
336
368
< ; md-select name=" ; users" ; id=" ; users" ; multiple v-model=" ; users" ;> ;
361
393
export default {
362
394
data: () => ({
363
395
food: '',
364
- users: [
365
- 'jim_halpert',
366
- 'michael_scott'
367
- ]
396
+ users: [],
397
+ options: [
398
+ { id: 1, name: 'a' },
399
+ { id: 2, name: 'b' },
400
+ { id: 3, name: 'c' },
401
+ { id: 4, name: 'd' },
402
+ { id: 5, name: 'e' }
403
+ ],
404
+ items: []
368
405
})
369
406
};
370
407
</code-block >
400
437
country: ' ' ,
401
438
font: ' ' ,
402
439
food: ' ' ,
403
- users: [
404
- ' jim_halpert' ,
405
- ' michael_scott'
406
- ]
440
+ users: [],
441
+ options: [
442
+ { id: 1 , name: ' a' },
443
+ { id: 2 , name: ' b' },
444
+ { id: 3 , name: ' c' },
445
+ { id: 4 , name: ' d' },
446
+ { id: 5 , name: ' e' }
447
+ ],
448
+ items: []
407
449
}),
408
450
methods: {
409
451
setPulpFiction () {
Original file line number Diff line number Diff line change 21
21
22
22
export default {
23
23
props: {
24
- value: [String , Boolean , Number ]
24
+ value: [String , Boolean , Number , Object ]
25
25
},
26
26
data : () => ({
27
27
parentSelect: {},
Original file line number Diff line number Diff line change 60
60
watch: {
61
61
value (value ) {
62
62
this .setTextAndValue (value);
63
+ this .selectOptions (value);
63
64
},
64
65
disabled () {
65
66
this .setParentDisabled ();
81
82
setParentPlaceholder () {
82
83
this .parentContainer .hasPlaceholder = !! this .placeholder ;
83
84
},
85
+ selectOptions (modelValue ) {
86
+ const optionsArray = Object .keys (this .options ).map ((el ) => this .options [el]);
87
+
88
+ if (optionsArray && optionsArray .length ) {
89
+ optionsArray .filter ((el ) => modelValue .indexOf (el .value ) !== - 1 )
90
+ .forEach ((el ) => {
91
+ el .check = true ;
92
+ });
93
+ }
94
+ },
84
95
getSingleValue (value ) {
85
96
let output = {};
86
97
124
135
return {};
125
136
},
126
137
setTextAndValue (modelValue ) {
127
- const output = this .multiple ? this .getMultipleValue (modelValue) : this .getSingleValue (modelValue);
138
+ const output = this .multiple ?
139
+ this .getMultipleValue (modelValue) :
140
+ this .getSingleValue (modelValue);
128
141
129
142
this .selectedValue = output .value ;
130
143
this .selectedText = output .text ;
You can’t perform that action at this time.
0 commit comments