English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Recently, due to work needs, users can try the multi-select effect by clicking the dropdown box, and the effect is roughly as shown in the figure below:
The code to implement it is as follows:
<select id="iweekDay" class="col-sm-4 form-control easyui-combobox " name="state" data-options="multiple:true,multiline:true" style="width:350px;height:35px" > <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> </select>
The most important thing is: multiple: true means that the dropdown box can be multi-selected. If it is single selection: multiple: false single selection
Below is a summary of the retrieval and assignment of combobox
2,assignment
(1) Single-select assignment setValue
$('#Id').combobox('setValue','key')
(2) Multi-select assignment setValues
The multi-select key value is an array, $('#Id').combobox('setValues','key1,key2,key3'.split(','))
Note: 'key1,key2,key3'.split(',') splits the string into an array, because the second parameter of combobox is an array
3.retrieve value
(1) Single-select value getValue
$('#Id').combobox('getValue')
(2) Multi-select value getValues
The multi-select key value is an array, $('#Id').combobox('getValues')
Note: The retrieved value is an array. If you want to convert it to a comma-separated string, for example (1,2,3"),using the join method, the code is as follows:
var str=$('#Id').combobox('getValues').join(",");
PS: Let's see the complete code for assigning and retrieving values of easyui selectbox below
Assign and retrieve values
// Redefine the banner var storeName_value = '@ViewBag.StoreName'; var department_value = '@ViewBag.Department'; var changeDate_value = '@ViewBag.ChangeDate'; $('#StoreName option:selected').text(storeName_value); $('#Department option:selected').text(department_value); //$('#StoreName').combobox('setValue', storeName_value); //$('#Department').combobox('setValue', department_value); // lier le bouton de recherche $('#this_submit').bind('click', function () { // var st = $('#StoreName option:selected').text().trim(); // var dep = $('#Department option:selected').text().trim(); var st = $('#StoreName').combobox('getValue'); var dep = $('#Department').combobox('getValue'); var changeDate = $('#datepicker').val(); var href = '../'; href += '&storeName=' + st + '&department=' + dep + '&changeDate=' + changeDate; href += '&page='1&size=8'; window.location.href = href; });
Ce que j'ai présenté à l'éditeur est la combinaison de la valeur de récupération et d'affectation du ComboBox Easyui, j'espère que cela peut aider tout le monde. Si vous avez des questions, laissez un message, l'éditeur répondra à temps. Merci également de votre soutien au site de tutoriels à cris !