这是 extjs 4 传递参数 groupid
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
autoLoad: true,
url: 'tree1.php',
extraParams :{groupid:'2'},
// Here Magic comes
},
actionMethods: 'GET',
sorters: [{
property: 'leaf',
direction: 'ASC'
}, {
property: 'text',
direction: 'ASC'
}]
});
树1.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['node'];
$group_id = $_GET['groupid'];
if ($parent_id > 0){
}else{
$parent_id = "0";
}
// 1) Remove false as checked
if ($group_id > 0){
$query = "SELECT * FROM (SELECT GroupID as id,GroupName as text,0 as parent_id FROM tbl_group UNION SELECT DeviceID as id,VehicleNo as text,GroupID as parent_id FROM Tbl_device) as u WHERE parent_id = '".$parent_id."' AND id= '".$group_id."' ORDER BY u.text ASC";
}else{
$query = "SELECT * FROM (SELECT GroupID as id,GroupName as text,0 as parent_id FROM tbl_group UNION SELECT DeviceID as id,VehicleNo as text,GroupID as parent_id FROM Tbl_device) as u WHERE parent_id = '".$parent_id."' ORDER BY u.text ASC";
}
$rs = mysql_query($query);
$arr = array();
while($obj = mysql_fetch_object($rs)) {
$qq = mysql_query("SELECT * FROM tbl_device WHERE GroupID='". $obj->id ."'");
if (mysql_num_rows($qq) > 0) {
// if have a child
//echo "have child";
$obj->leaf = "false";
//$obj->cls = 'folder';
} else {
// if have no child
$obj->leaf = "true";
//$obj->cls = 'file';
}
// 2) If no leaf then destroy the attribute
if($obj->leaf != "false"){
// 1) set checked attribute with an boolean value
$obj->checked = false;
}
$arr[] = $obj;
}
//echo $parent_id;
echo json_encode($arr);
?>
萤火虫截图
问题
当我使用 FireBug 获取参数时,没有任何 groupid 参数。为什么?我完全不知道这是怎么回事。
请帮助非常感谢你!