初学JavaScript_03(ExtJs Grid的简单使用)
更新时间:2008年10月02日 00:49:41 作者:
Ext JS Grid的简单使用:(从土豆的文档中学到)
<html>
<head>
<title>Ext中的Grid例子</title>
<link rel="stylesheet" type="text/css"
href="../AllRes/resources/css/ext-all.css"/>
<script type="text/javascript" src="../AllRes/adapter/ext/ext-
base.js"></script>
<script type="text/javascript" src="../AllRes/ext-all.js"></script>
<script>
//ID排序
Ext.onReady(function(){
var cm = new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id',sortable:true},
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}
]) ;
var data = [
['1','name1','descn1'],
['2','name2','descn2'],
['3','name3','descn3'],
['4','name4','descn4'],
['5','name3','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() ;
var grid = new Ext.grid.GridPanel({
el:'grid',
ds: ds,
cm: cm
}) ;
grid.render() ;
}) ;
</script>
</head>
<body>
<div id="grid"></div>
</body>
</html>
<head>
<title>Ext中的Grid例子</title>
<link rel="stylesheet" type="text/css"
href="../AllRes/resources/css/ext-all.css"/>
<script type="text/javascript" src="../AllRes/adapter/ext/ext-
base.js"></script>
<script type="text/javascript" src="../AllRes/ext-all.js"></script>
<script>
//ID排序
Ext.onReady(function(){
var cm = new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id',sortable:true},
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}
]) ;
var data = [
['1','name1','descn1'],
['2','name2','descn2'],
['3','name3','descn3'],
['4','name4','descn4'],
['5','name3','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() ;
var grid = new Ext.grid.GridPanel({
el:'grid',
ds: ds,
cm: cm
}) ;
grid.render() ;
}) ;
</script>
</head>
<body>
<div id="grid"></div>
</body>
</html>
最新评论