View Full Version : Combo box not loading

16 May 2011, 2:44 AM
I'm trying to load a combo box by fetching data from database. And it is not loading.

Here's the php code:

function rcities(){
$rowresult = $this->mradio->getCities();

foreach($rowresult->result() as $row){
$item[] = $row->city;
echo '{rows:'.json_encode($item).'}';

EXTJS code:

var cities = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: [{name: 'myId'},{name:'city'}],
root: 'rows'
proxy: new Ext.data.HttpProxy({
method: 'POST'
autoLoad: true

xtype: 'combo',
name: 'city',
fieldLabel: 'City',
store: cities,
triggerAction: 'all',
displayField: 'city',
valueField: 'myId',
autoHeight: true,
editable: false,
width: 200

This is the JSON i get from the php:


16 May 2011, 3:51 AM
Should your JSON not be something like:

{rows:[{"myId": 1, "city": "City1"},{"myId": 2, "city": "City2"}]}

16 May 2011, 4:44 AM
I tried this. But didn't work