View Full Version : want to fetch data for my combo in formpanel

11 May 2010, 3:10 AM

i have one combo in my formpanel

xtype: 'combo',
name: 'genre',
fieldLabel: 'Genre',
mode: 'local',
store: genres,
width: 120

and for fetching data in i have following code..

var genres = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['companyID', 'company'],
root: 'rows'
proxy: new Ext.data.HttpProxy({
url: 'categories.php'
autoLoad: true

and in categories.php...

//database parameters
$user='root'; //user
$pw='bij123'; //user password
$db='test'; //name of database
$table='stock'; //name of table data stored in

$taxRate = 0.06;

//make database connection
$connection = mysql_connect("localhost", $user, $pw) or
die("Could not connect: " . mysql_error());
mysql_select_db($db) or die("Could not select database");

// connection to database goes here
$result = mysql_query('SELECT companyID,company FROM stock');
If (mysql_num_rows($result) > 0) {
while ($obj = mysql_fetch_object($result)) {
$arr[] = $obj;
echo '{rows:'.json_encode($arr).'}';

m having following code..
please help me how to get data from db to show in combo..



11 May 2010, 7:55 AM
Your combo's displayField doesn't match any of the fields in your store. Try:

// ...
displayField: 'company',
valueField: 'companyID',
// ...

Also see: http://www.extjs.com/learn/Ext_FAQ_ComboBox