PDA

View Full Version : combobox and json reader value problem



alien3d
18 Dec 2009, 5:33 PM
The problem was if i used Json Data Reader.It choose the value but the displayField appear valueField instead and also not selected at first.



var dist_store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : 'information.php?method=read&type=district',
method : 'get'
}),
reader : dist_reader,
remoteSort : false
});
...{ xtype : 'combo',
name : 'dist_code',
id : 'dist_code',
fieldLabel : 'District Code',
allowBlank : false,
triggerAction : 'all',
store : dist_store,
valueField : 'value',
displayField : 'text',
mode : 'remote',
value : '<?php print $gdata['dist_code']; ?>'
}

Normal Store Work and it pick the right selected value

{ xtype : 'combo',
name : 'dist_code',
id : 'dist_code',
fieldLabel : 'District Code',
allowBlank : false,
triggerAction : 'all',
store : [ [1,'new castle'],[2,'manchester'],[4,'liverpool']],
mode : 'remote',
value : '<?php print $gdata['dist_code']; ?>'
}

fay
19 Dec 2009, 5:18 AM
You forgot to post how you are creating/defining "dist_reader"

Condor
19 Dec 2009, 6:15 AM
You are trying to set the value of the combobox before the store is loaded, so how is it supposed to know the district name of the district code?

Use this override (http://www.extjs.com/forum/showthread.php?p=400274#post400274) to make combobox wait until the store is loaded before setting the value.

alien3d
19 Dec 2009, 4:42 PM
Thanks .the overide work perfectly.=D>