ExtJS Grid一直无法显示资料,麻烦高手帮忙
我的Ext.grid.Panel一直没办法显示资料,可以麻烦帮我看一下吗?index.php---------------------------------------...
我的Ext.grid.Panel一直没办法显示资料,可以麻烦帮我看一下吗?
index.php-----------------------------------------------------------------------------
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test</title>
<script type="text/javascript" src="../ext-4.2.1.883/examples/shared/include-ext.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function(){
//-----------------------------------------------------------------------------------
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'test1', type: 'string'},
{name: 'test2', type: 'string'},
{name: 'test3', type: 'string'}
]
});
var myStore = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url: 'storeRubrica.php',
reader: {
type: 'json',
//root: 'test'
}
},
autoLoad: true
});
//--------------------------------------------------------------------------------
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: myStore,
frame:true,
columns: [
{ text: 'test1', dataIndex: 'test1', flex: 1 },
{ text: 'test2', dataIndex: 'test2', flex: 1 },
{ text: 'test3', dataIndex: 'test3', flex: 1 }
],
height: 500,
width: 1000,
renderTo:Ext.getBody()
});
});
</script>
<div id="mygrid"></div>
</body>
</html>
storeRubrica.php------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
//------------------------------------------------
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'xxxx';
$dbname = 'mai';
$db = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $db);
mysql_query("SET NAMES UTF8");
mysql_query("SET CHARACTER_SET_CLIENT=UTF8");
mysql_query("SET CHARACTER_SET_RESULTS=UTF8");
mysql_set_charset("UTF8");
$esito = array();
$str = "SELECT * FROM test";
$rst = mysql_query($str);
while ( $arr = mysql_fetch_array($rst) )
{
$esito[] = $arr;
}
echo json_encode($esito);
?>
</body>
</html>
myslq--------------------------------------------------------------------------------------
json-----------------------------------------------------------------------------------------------------
[{"0":"test","test1":"test","1":"test","test2":"test","2":"test","test3":"test"}] 展开
index.php-----------------------------------------------------------------------------
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test</title>
<script type="text/javascript" src="../ext-4.2.1.883/examples/shared/include-ext.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function(){
//-----------------------------------------------------------------------------------
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'test1', type: 'string'},
{name: 'test2', type: 'string'},
{name: 'test3', type: 'string'}
]
});
var myStore = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url: 'storeRubrica.php',
reader: {
type: 'json',
//root: 'test'
}
},
autoLoad: true
});
//--------------------------------------------------------------------------------
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: myStore,
frame:true,
columns: [
{ text: 'test1', dataIndex: 'test1', flex: 1 },
{ text: 'test2', dataIndex: 'test2', flex: 1 },
{ text: 'test3', dataIndex: 'test3', flex: 1 }
],
height: 500,
width: 1000,
renderTo:Ext.getBody()
});
});
</script>
<div id="mygrid"></div>
</body>
</html>
storeRubrica.php------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
//------------------------------------------------
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'xxxx';
$dbname = 'mai';
$db = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $db);
mysql_query("SET NAMES UTF8");
mysql_query("SET CHARACTER_SET_CLIENT=UTF8");
mysql_query("SET CHARACTER_SET_RESULTS=UTF8");
mysql_set_charset("UTF8");
$esito = array();
$str = "SELECT * FROM test";
$rst = mysql_query($str);
while ( $arr = mysql_fetch_array($rst) )
{
$esito[] = $arr;
}
echo json_encode($esito);
?>
</body>
</html>
myslq--------------------------------------------------------------------------------------
json-----------------------------------------------------------------------------------------------------
[{"0":"test","test1":"test","1":"test","test2":"test","2":"test","test3":"test"}] 展开
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询