Title: Combobox - How should I build a Drop Down List from database Post by: correohs on February 03, 2013, 12:12:20 PM I want to made a dropdown list using the easyui. I tried different option with out luck
<input class="easyui-combobox" name="lo_client_id" data-options=" url:'get_clients.php', valueField:'client_code', textField:'client_desc', panelHeight:'auto' "> With the combobox_data1.json file works my get_client_php does not work. I read that formatter can help on it. I dont know how to uses it, even when I saw examples of it I couldn't figure it out. Could Anyone could help me on it? Thanks My get_client_php bring this info. {"total":"4","rows": [{ "client_id":"1","client_code":"341896","client_desc":"Subway,Inc","client_location_id":"0","client_location_desc":"" },{ "client_id":"2","client_code":"341897","client_desc":"Wendy,Inc","client_location_id":"0","client_location_desc":"" },{ "client_id":"4","client_code":"341898","client_desc":"McDonald,Inc","client_location_id":"0","client_location_desc":"" },{ "client_id":"6","client_code":"351889","client_desc":"Taco Bell, Inc","client_location_id":"0","client_location_desc":"" }]} The example combobox_data1.json file bring this info [{ "id":1,"text":"Java","desc":"Write once, run anywhere" },{ "id":2,"text":"C#","desc":"One of the programming languages designed for the Common Language Infrastructure" },{ "id":3,"text":"Ruby","selected":true, "desc":"A dynamic, reflective, general-purpose object-oriented programming language" },{ "id":4,"text":"Perl","desc":"A high-level, general-purpose, interpreted, dynamic programming language" },{ "id":5,"text":"Basic","desc":"A family of general-purpose, high-level programming languages" }] Title: Re: Combobox - How should I build a Drop Down List from database Post by: stworthy on February 03, 2013, 07:13:58 PM The data to fill the combobox list should be an array object. To solve this issue, make the 'get_client.php' returning json array:
Code: [{ Another way to solve this issue is to override the loader object. Code: var cloader = function(param, success, error){ Code: <input class="easyui-combobox" Title: Re: Combobox - How should I build a Drop Down List from database Post by: correohs on February 04, 2013, 07:07:29 AM Thanks!
I modified my php file $items = array(); while($row = mysql_fetch_object($rs)){ array_push($items, $row); } $result = $items; echo json_encode($result); |