EasyUI
Home
Demo
Tutorial
Documentation
Download
Extension
Contact
Forum
EasyUI Forum
May 07, 2024, 06:13:04 AM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
EasyUI Forum
>
General Category
>
EasyUI for jQuery
>
ComboBox changes using select
Pages: [
1
]
« previous
next »
Print
Author
Topic: ComboBox changes using select (Read 4929 times)
karmac
Newbie
Posts: 1
ComboBox changes using select
«
on:
November 26, 2013, 03:26:20 AM »
Hi,
I am trying to figure out how to update/append the contents/options of easyui-combobox using javascript after fetching json data from server.
my script inside the .html
var xmlhttp = getRequestObject();
xmlhttp.onreadystatechange = function()
{
if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
try {
var xmlDocument = xmlhttp.responseText;
var dpanel = document.getElementById("reportdate");
if(xmlDocument !== null) {
var valJS = JSON.parse(xmlDocument.toString());
var output = "";
$.each(valJS, function(key, obj) {
output += '<option value="'+ obj +'">'+ obj +'</option>';
});
dpanel.innerHTML=output;
}
}
catch (err) {
alert("error=" + err.message);
}
}
};
the html code is as follows
<div id="datepanel">
<select name="reportdate" id="reportdate" style="width:200px;" class="easyui-combobox">
</select>
</div>
With the above code once the page is loaded, i am able to see <options> inside the select updated, but the same is not reflected in the combobox[ie the combo is empty].
On the other hand, if i remove the class="easyui-combobox", the the options are visible on the page.
I dont know what i am doing wrong. Any help would be greatly appreciated.
Logged
stworthy
Administrator
Hero Member
Posts: 3581
Re: ComboBox changes using select
«
Reply #1 on:
November 26, 2013, 08:19:08 AM »
Calling 'loadData' method is the simplest way to update combobox's data.
Code:
var data = ... // get data
$('#reportdata').combobox('loadData', data);
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> News
=> General Discussion
=> EasyUI for jQuery
=> EasyUI for Angular
=> EasyUI for Vue
=> EasyUI for React
=> Bug Report
Loading...