Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'DeviceID', type: 'string'},
{name: 'VehicleNo', type: 'string'}
]
});
var store1 = new Ext.data.JsonStore({
// store configs
model: 'User',
storeId: 'myStore',
proxy: {
type: 'ajax',
url: 'combobox.php',
id:'1', //show only the group ID is 1,this id are flexible,not necessary is 1
fields: ['DeviceID','VehicleNo']
}
});
这是工具栏上的代码
xtype: 'combobox',
labelWidth: 50,
labelAlign: 'right',
fieldLabel: 'Vehicle',
name: 'state1',
width :180,
store: store1,
valueField: 'DeviceID',
displayField: 'VehicleNo',
typeAhead: true,
queryMode: 'local',
emptyText: 'Select a Vehicle...'
组合框.php
<?php
mysql_connect("localhost", "root", "") or die("Could not connect");
mysql_select_db("db_gps") or die("Could not select database");
$parent_id = $_GET['id'];
$query = "SELECT DeviceID as id, VehicleNo as text FROM Tbl_device WHERE GroupID='".$parent_id."' ORDER BY text ASC";
$rs = mysql_query($query);
$arr = array();
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
echo json_encode($arr);
?>
mysql数据库
delimiter $$
CREATE TABLE `tbl_device` (
`MainID` int(11) NOT NULL AUTO_INCREMENT,
`DeviceID` varchar(11) NOT NULL,
`VehicleNo` varchar(45) NOT NULL,
`GroupID` varchar(45) NOT NULL,
`AutoPic` bit(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`MainID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1$$
问题
1)我无法显示组合框数据?我的代码有问题吗?请帮忙,thanks.on我的代码我试图传递id的参数,你可以从我的代码中看到我将id:1传递给combobox.php,这个传递值是灵活的,不需要只有1 2)这个代码数据型号是否正确?带有 DeviceID 和 VehicleNo 字段