下午调了一下ExtJS,试了一下GridPanel,结果代码都正确,就是页面上没反应。调了半天,才发现,GridPanel没有在网页中渲染。。
以下是下午试验HTML代码
///
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
<script type="text/javascript" src="../examples.js"></script>
<script>
Ext.onReady(function(){
var cm = new Ext.grid.ColumnModel([
{header:'编号', dataIndex: 'id'},
{header:'名称',dataIndex: "name"},
{header:'描述',dataIndex: 'descn'}
]);
var data = [
['1','name1','descn1'],
['2','name2','descn2'],
['3','name3','descn3'],
['4','name4','descn4'],
['5','name5','descn5']
];
var ds = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(data),
reader: new Ext.data.ArrayReader({},[{name:'id'},{name:'name'},{name:'descn'}])
});
ds.load();
//ds要对应两个部分:proxy和reader。proxy告诉我们从哪里获得数据,
//reader告诉我们如何解析这个数据。
var grid = new Ext.grid.GridPanel(
{
title:'demo',
height:200,
region:'center',
frame:true,
store: ds,
cm: cm
});
//这里设定了网页渲染---
grid.render("grid-example");
});
</script>
<--! 这里是渲染区域 -->
<div id="grid-example"></div>