TreeStore Pass参数 - EXTJS 4

时间:2013-02-17 21:48:50

标签: php javascript extjs extjs4 parameter-passing

这是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'
                    }]
    });

tree1.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屏幕截图

enter image description here

问题

当我使用FireBug获取参数时,没有任何groupid参数。为什么?我完全不知道这有什么不妥。
请非常感谢你!

1 个答案:

答案 0 :(得分:0)

看起来不错,但是extraParams :{'groupid':'2'}, - &gt;串