<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="./extjs4/resources/css/ext-all.css">
<script type="text/javascript" src="./extjs4/bootstrap.js"></script>
<script type="text/javascript" src="./extjs4/ext-all.js"></script>
<script>
Ext.onReady(function(){
// alert("hello world");
// Ext.MessageBox.alert("hello","hello world");
var data=[ [1, 'EasyJWeb', 'EasyJF','www.easyjf.com'],
[2, 'jfox', 'huihoo','www.huihoo.org'],
[3, 'jdon', 'jdon','www.jdon.com'],
[4, 'springside', 'springside','www.springside.org.cn'] ];
var store=new Ext.data.SimpleStore({data:data,fields:["id","name","organization","homepage"]});
var grid = new Ext.grid.GridPanel({
renderTo:"hello",
title:"中国Java开源产品及团队",
height:150,
width:600,
columns:[{header:"项目名称",dataIndex:"name"},
{header:"开发团队",dataIndex:"organization"},
{header:"网址",dataIndex:"homepage"}],
store:store,
autoExpandColumn:2
});
});
</script>
首先你用的是4版本 而你的写法确是2,3版本的写法
最关键的是 renderTo:"hello", 但是没有
[code="java"] <br> Ext.onReady(function(){<br> //创建表格数据<br> var datas = [<br> [100,'张三',24],<br> [200,'李四',30],<br> [300,'王五',29]<br> ];<br> //创建Grid表格组件<br> Ext.create('Ext.grid.Panel',{<br> title : '简单Grid表格示例',<br> renderTo: Ext.getBody(),<br> width:200,<br> height:130,<br> frame:true,<br> viewConfig: {<br> forceFit : true,<br> stripeRows: true//在表格中显示斑马线<br> },<br> store: {//配置数据源<br> fields: ['id','name','age'],//定义字段<br> proxy: {<br> type: 'memory',//Ext.data.proxy.Memory内存代理<br> data : datas,//读取内嵌数据<br> reader : 'array'//Ext.data.reader.Array解析器<br> },<br> autoLoad: true//自动加载<br> },<br> columns: [//配置表格列<br> {header: "id", width: 30, dataIndex: 'id', sortable: true},<br> {header: "姓名", width: 80, dataIndex: 'name', sortable: true},<br> {header: "年龄", width: 80, dataIndex: 'age', sortable: true}<br> ]<br> });<br> });<br>
没有发现id为hello的div
请检查代码
[code="java"]
renderTo:"hello"
[/code]
把你的ext代码放在body里边试试!