<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="../ext/ext-base.js" type="text/javascript"></script>
<script src="../ext/ext-all.js" type="text/javascript"></script>
<link rel="stylesheet" href="../ext/resources/css/ext-all.css" type="text/css" />
</head>
<script type="text/javascript">
Ext.onReady(function(){
var data={ [color=#FF0000]【提示undefined为空或者不是对象】
results:5,
rows:[
{id:0,name:'tom',age:24},
{id:1,name:'tom',age:24},
{id:2,name:'tom',age:24}
]
};
var jsonStore = new Ext.data.JsonStore({
data:data,
fields:[
{name:'personId',mapping:'id'},
{name:'personName',mapping:'name'}
]
});
new Ext.grid.GridPanel({
title:'grid-store',
applyTo:'grid-div',
width:430,
height:150,
frame:true,
store:jsonStore,
columcs:[
{header:'id',width:30,dataIndex:'personId'},
{header:'姓 名',width:30,dataIndex:'personName'},
]
})
});
</script>
<body>
<div id="grid-div"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="../ext/ext-base.js" type="text/javascript"></script>
<script src="../ext/ext-all.js" type="text/javascript"></script>
<link rel="stylesheet" href="../ext/resources/css/ext-all.css" type="text/css" />
</head>
<script type="text/javascript">
Ext.onReady(function(){
var data={ [color=#FF0000]【提示undefined为空或者不是对象】
results:5,
rows:[
{id:0,name:'tom',age:24},
{id:1,name:'tom',age:24},
{id:2,name:'tom',age:24}
]
};
var jsonStore = new Ext.data.JsonStore({
data:data,
fields:[
{name:'personId',mapping:'id'},
{name:'personName',mapping:'name'}
]
});
new Ext.grid.GridPanel({
title:'grid-store',
applyTo:'grid-div',
width:430,
height:150,
frame:true,
store:jsonStore,
columcs:[
{header:'id',width:30,dataIndex:'personId'},
{header:'姓 名',width:30,dataIndex:'personName'},
]
})
});
</script>
<body>
<div id="grid-div"></div>
</body>
</html>
var data=[
['01','Name01'],['02','Name02'],['03','Name03'],['04','Name04']
];
$sqlservname="root";
$sqlservpws="123456";
$sqlname="lock1";
$db=mysql_connect($servname,$sqlservname,$sqlservpws) or die("数据库连接失败");
mysql_select_db($sqlname,$db);
$sql = "select * from t_operater";
$result =mysql_query($sql);
$rows = mysql_num_rows($result);
while($obj = mysql_fetch_object($result))
{
$arr[] = $obj;
}echo '({"total":"'.$rows.'","results":'.json_encode($arr).'})';
?>
运行结果是
({"total":"204","results":[{"operater_id":"-9999","org_id":null,"phone":null,"name":"??IE??","pwd":"-9999","state":"A"},{"operater_id":"1010","org_id":"2","phone":"15316707210","name":"??10","pwd":"10","state":"A"},{"operater_id":"1111","org_id":"2","phone":"15316707205","name":"???","pwd":"111111","state":"X"},{"operater_id":"9999","org_id":"2","phone":"15316707209","name":"??9","pwd":"111111","state":"A})
name是乱码