Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Ext树,数据显示在控制台中,但不显示在页面上_Php_Html_Mysql_Extjs_Tree - Fatal编程技术网

Php Ext树,数据显示在控制台中,但不显示在页面上

Php Ext树,数据显示在控制台中,但不显示在页面上,php,html,mysql,extjs,tree,Php,Html,Mysql,Extjs,Tree,我的数据显示在控制台中,但不显示在ExtJs树中 我的php文件 $data = array(); $sql = ""; if (!isset($_POST['node'])) { // first select the top node that have no parent $sql = "SELECT id_no,value_data FROM extjs_tree WHERE parent IS NULL"; } els

我的数据显示在控制台中,但不显示在ExtJs树中

我的php文件

    $data = array();

    $sql = "";

    if (!isset($_POST['node'])) {
        // first select the top node that have no parent
        $sql = "SELECT id_no,value_data FROM extjs_tree WHERE parent IS NULL";
    } else {
        // select data with parent_id = $_POST['node']
        $sql = "SELECT id_no, value_data FROM extjs_tree WHERE parent = '". $_POST['node'] ."'";                                            
    }   

    $q = mysql_query($sql);

    while ($r = mysql_fetch_array($q)) {
        // check if have a child node                           
        $qq = mysql_query("SELECT id_no, value_data FROM extjs_tree WHERE parent = '". $r['id'] ."'");

        if (mysql_num_rows($qq) > 0) {
            // if have a child
            $r['leaf'] = false;
            $r['cls'] = 'folder';
        } else {
            // if have no child
            $r['leaf'] = true;
            $r['cls'] = 'file';
        }
        $data[] = $r;

    }               


    echo json_encode($data);
我的JS文件

Ext.require([
    'Ext.tree.*',
    'Ext.data.*',
    'Ext.tip.*'
]);

Ext.onReady(function() {
    Ext.QuickTips.init();

    var store = Ext.create('Ext.data.TreeStore', {
        proxy: {
            type:'ajax',
            actionMethods:'post',
            url:'get-nodes.php'


        },
        root: {
            text: 'Root Node',
            id: 'root_node',
            expanded: true
        },
        folderSort: true,
        sorters: [{
            property:'text',
            direction:'ASC'
        }]
    });

    var tree = Ext.create('Ext.tree.Panel', {
        store: store,
        renderTo: 'tree_el',
        height: 300,
        width: 250,
        title: 'Products Display'
    });
});
我得到了正确的树,我可以看到控制台中的数据。但是我看不到ExtJs显示值

我现在的成绩

我的预期结果应该是


每个响应项都必须包含
文本
字段。正如我从您的请求-响应图像中看到的,您没有发送
text
字段。响应应如下所示:

[{
    "id": 2,
    "text": "Fruits", // this field is required
    ...
},
    ...
]

在您的情况下,您还可以将以下字段添加到存储:

{
  name: 'text',
  mapping: 'value'
}

旁注:第
$sql=“从extjs_树中选择id_no,value_数据,其中parent=”,行中存在巨大的安全漏洞$_POST['node']。“'”。您需要更改
文本:
值:
,或者以不同的方式映射您的模型,因为您使用的是默认节点映射。商店中是否需要它?@StrataGeeksCEO,否。作为响应。否则,你必须修改你的模型,正如Thomas所说。我的商店看起来像这样,它不工作
var store=Ext.create('Ext.data.TreeStore',{proxy:{type:'ajax',actionMethods:'post',url:'get-nodes.php',name:'text',mapping:'value'
似乎您已将name和mapping字段作为单独的字段添加到存储代理中。请参阅