Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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
Extjs I';我正试图用数据库和I';我在向gridpanel显示数据时遇到了麻烦_Extjs_Extjs Mvc_Extjs5 - Fatal编程技术网

Extjs I';我正试图用数据库和I';我在向gridpanel显示数据时遇到了麻烦

Extjs I';我正试图用数据库和I';我在向gridpanel显示数据时遇到了麻烦,extjs,extjs-mvc,extjs5,Extjs,Extjs Mvc,Extjs5,我试图用数据库将ExtJs连接到PHP,但在向gridpanel显示数据时遇到了问题,我很困惑为什么gridpanel中没有显示数据,firebug中也没有错误。任何人都可以检查并纠正我,或者教我如何用PHP创建一个简单的gridpanel。我正在使用ExtJS5 //应用程序/商店/ Ext.define('TestPhp.store.Employee', { extend: 'Ext.data.JsonStore', alias: 'store.employees',

我试图用数据库将ExtJs连接到PHP,但在向gridpanel显示数据时遇到了问题,我很困惑为什么gridpanel中没有显示数据,firebug中也没有错误。任何人都可以检查并纠正我,或者教我如何用PHP创建一个简单的gridpanel。我正在使用ExtJS5

//应用程序/商店/

Ext.define('TestPhp.store.Employee', {
      extend: 'Ext.data.JsonStore',
      alias: 'store.employees',
      model: 'TestPhp.model.Employ',
    proxy: {
        type: 'ajax',
        url: 'test.php',
        reader: {
            type: 'json',
            rootPropety: 'data'
        }
    },   });
//应用程序/模型/

Ext.define('TestPhp.model.Employ', {
     extend: 'Ext.data.Model',
    fields: ['name','bounty','power'],    
});
//app/view/main/

 Ext.define('TestPhp.view.main.Grid', {
    extend: 'Ext.Panel',
    xtype: 'gridp',

require:['TestPhp.store.Employee'],

    store: 'Employee',
 items:[{
            style: 'padding-top: 10px;',
            xtype: 'grid',
            style: 'margin-top:5px;margin-left:10px;',
            columns : [

                {
                text     : 'Name',
                width    : '40%',
                sortable : false,
                dataIndex: 'name'
            },
            {
                text     : 'Bounty',
                width    : '30%',
                sortable : true,
                dataIndex: 'bounty'
            },
            {
                text     : 'Power',
                width    : '30%',
                sortable : true,
                dataIndex: 'power'
            }

            ],

            width: '100%'
        }],
  });
//我的php文件

<?php

 mysql_connect("localhost", "root", "") or
  die("Could not connect: " . mysql_error());
  mysql_select_db("test_db");

$query= "SELECT * FROM pirate";
$result= mysql_query($query);

    $return_arr= array();

    while($rows = mysql_fetch_array($result, MYSQL_ASSOC)){
            // $row_array['id']=$rows['id'];
            $row_array['name']=$rows['name'];
            $row_array['bounty']=$rows['bounty'];
            $row_array['power']=$rows['power'];

            array_push($return_arr, $row_array);
}

$ans = array('success' => true, );
$ans['data'] = $return_arr;
header('Content-Type: application/json');
print json_encode($ans);
exit;

?>

这是php文件的输出


{“成功”:正确,“数据”:[{“名称”:“luffy”,“赏金”:“400000000”,“权力”:“gum gum no mi and haki”},{“名称”:“zorro”,“赏金”:“3000000000”,“权力”:“3剑风格和haki”},{“名称”:“sanji”,“赏金”:“100000000”,“权力”:“黑脚风格和haki”},{“名称”:“Ace”,“赏金”:“400000000”,“权力”:“flare flare flare no mi and haki”},{“名称”:“sabo”,“赏金”:“40000000000”,“power”:“unknown”},{“name”:“rayleigh”,“bounty”:“unknown”,“power”:“unknown”}]}

Evan的答案,代码为:替换

extend: 'Ext.Panel',

然后,将autoLoad:true添加到存储区或在创建网格之前加载存储区。根据您的用例调整此代码:

this.getStore('Employee').load()
Ext.widget('gridp')

首先,您的代码没有扩展网格面板。其次,您在哪里创建网格?在哪里加载存储?您是否检查它是否发出ajax请求?
this.getStore('Employee').load()
Ext.widget('gridp')