以下代码;var cm = new Ext.grid.ColumnModel([ 缺少对象

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="Ext/extjs4.0/resources/css/ext-all.css">
<script type="text/javascript" src="Ext/extjs4.0/bootstrap.js"></script>
<script type="text/javascript" src="Ext/extjs4.0/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var cm = new Ext.grid.ColumnModel([
{header:'曲目编号', dataIndex:'music_id'},
{header:'曲目名称', dataIndex:'music_name'},
{header:'作曲家', dataIndex:'composer'},
{header:'演奏乐器', dataIndex:'instrument'}
]);

var data = [
['001', 'Oasis', 'Kotaro Oshio', '吉他'],
['002', 'Classical Gas', 'Tommy.Emmanuel','吉他'],
['003', 'THIS WAY', 'Depapepe', '吉他']
];
var store = new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader([
{name:'music_id'},
{name:'music_name'},
{name:'composer'},
{name:'instrument'}
])
});
store.load();
var gridPanel = new Ext.grid.GridPanel({
renderTo:'gridPanel',
autoHeight:true,
store:store,
cm:cm
});

});
</script>
</head>

<body>
<div id="gridPanel"></div>
</body>
</html>

隔江千里
浏览 531回答 2
2回答

倚天杖

//不是很确切地说&nbsp;&nbsp;应该用GridPanel替代ColumnModel吧&nbsp;&nbsp;要不然光写这句就要报错了var&nbsp;cm&nbsp;=&nbsp;new&nbsp;Ext.grid.GridPanel([&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{header:'曲目编号',&nbsp;dataIndex:'music_id'},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{header:'曲目名称',&nbsp;dataIndex:'music_name'},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{header:'作曲家',&nbsp;dataIndex:'composer'},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{header:'演奏乐器',&nbsp;dataIndex:'instrument'}]);

当年话下

首先确保你的js文件的引用路径是否正确,第二,store.load();改为store.load(data);
打开App,查看更多内容
随时随地看视频慕课网APP