1

これは 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 を使用すると、グループ ID パラメータがありません。なぜですか? これは何が悪いのか全くわかりません。
助けてくださいどうもありがとうございました!

4

1 に答える 1

0

大丈夫に見えますが、extraParams :{'groupid':'2'},->文字列

于 2013-02-17T22:24:42.413 に答える