ext2.1表格处理

简单的表格显示,ext的面向对象思想。在表格中有很好的体现,在menu中更为明显
测试文件:
grid.html
<!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=gb2312" />
<title>ext2.1 表格实例</title>
<link type="text/css" rel="stylesheet" href="../_js/resources/css/ext-all.css" />
<script src="../_js/ext-base.js"></script>
<script src="../_js/ext-all.js"></script>
<script src="../_js/ext-lang-zh_CN.js"></script>
<script src="grid.js"></script>
</head>

<body>
<div id="grid">
</div>
</body>
</html>
grid.js:
// JavaScript Document
//cm:ColumnModel表格的列模型
Ext.onReady(function(){
Ext.QuickTips.init();
var cm = new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id',sortable=true},//按照id排序
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}
]);
var data = [
['1','name1','descn1'],
['2','name2','descn2'],
['3','name3','descn3'],
['4','name4','descn4'],
['5','name6','descn5']
];
var ds = new Ext.data.Store({
proxy : new Ext.data.MemoryProxy(data),
reader : new Ext.data.ArrayReader({},[
{name:'id'},
{name:'name'},
{name:'descn'}
])
});
/*
为了解决Store中的reader的name和grid中的cm的列值的对应问题,可以使用map
var ds = new Ext.data.Store({
proxy : new Ext.data.MemoryProxy(data),
reader : new Ext.dataArrayReader({},[
{name:'id',mapping:0},
{name:'name',mapping:1},
{name:'descn',mapping:2}
])
});
*/
ds.load();
var grid = new Ext.grid.GridPanel({
el : 'grid',
ds : ds,
cm : cm
});
grid.render();
});
阅读更多

关于EXT2.1 树的一个问题

09-18

最近学习ext,最开始是使用ext2.2做了一棵树动态从后台struts2的action里面读取json数据能够成功rn[code=JScript]rnExt.onReady(function()rn Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif'; rn rn var Tree = Ext.tree; rn rn var tree = new Tree.TreePanel(rn el:'tree-div',rn useArrows:true,rn autoScroll:true,rn animate:true,rn enableDD:true,rn containerScroll: true,rn loader:new Tree.TreeLoader(rn dataUrl:'TreeAjax.action',rn processResponse:function(response,node,callback) rn var data = response.responseText;rn var temp=Ext.decode(data);rn var json=temp["menuString"];rn try rn var o = eval("("+json+")");rn node.beginUpdate();rn for(var i = 0, len = o.length; i < len; i++)rn var n = this.createNode(o[i]);rn if(n)rn node.appendChild(n);rn rn node.endUpdate();rn if(typeof callback == "function")rn callback(this, node);rn rn catch(e)rn this.handleFailure(response);rn rn rn ),rn rn root: rn nodeType: 'async',rn text: 'ext Js',rn draggable:false,rn id:'source'rn rn );rn tree.on("click",function(node)rn Ext.MessageBox.alert(node.id);rn rn //Ext.genCmp("frame").dom.src="xx.action?id="+node.id;rn );rn rn tree.render();rn tree.getRootNode().expand();rn);rn[/code]rnrnrn后来在一个应用中又用到了ext2.1rn同样是一棵树,使用ext的Treeloader却不能从后台读取数据,用firebug调试显示根本就没有进入action,下面是JavaScript源代码rn[code=JScript]rn var root7 = new Ext.tree.AsyncTreeNode(id:"root7", text:"\u6811\u7684\u6839");rn 。。。。rn var myloader=new Ext.tree.TreeLoader(rn dataUrl:'TreeAjax.action' rn ); rn var tree7 = new Ext.tree.TreePanel(rn renderTo:"tree7",rn root:root7,rn animate:true, rn border:false, rn rootVisible:false,rn enableDD:true, rn containerScroll: true, rn loader:myloaderrn );rnrn[/code]rnrn请问下,上面的代码有什么问题啊,改怎么解决呢?rnrnrn

没有更多推荐了,返回首页