English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Easyui-Kombinationsbox - Wertabfrage und Zuweisung

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.retrieval

(1) Single-select retrieval getValue

$('#Id').combobox('getValue')

(2) Multi-select retrieval 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,3Use the join method, the code is as follows:

var str=$('#Id').combobox('getValues').join(',');

PS: Let's take a look at the complete code for assigning and retrieving values of easyui selectbox

Assigning and retrieving 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);
// bind searchBtn
$('#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;
});

Das oben Genannte ist die von mir vorgestellte Kombinationsbox von Easyui, deren Wert und Zuweisung, ich hoffe, es hilft Ihnen. Wenn Sie irgendwelche Fragen haben, hinterlassen Sie mir bitte eine Nachricht, ich werde rechtzeitig antworten. Ich danke auch sehr für die Unterstützung der Website 'Schrei Anleitung'!

Empfohlene Artikel