转自:http://di201yao.javaeye.com/blog/163443
- <SPAN class=hilite1>Ext</SPAN>.onReady(function(){
- var tb=new <SPAN class=hilite1>Ext</SPAN>.Toolbar('toolbar-div');//创建一个工具条
- tb.add(new <SPAN class=hilite1>Ext</SPAN>.Toolbar.SplitButton({
- t<SPAN class=hilite1>ext</SPAN>: '文件',
- cls: 'x-btn-t<SPAN class=hilite1>ext</SPAN>-icon blist',
- menu : {items: [
- {t<SPAN class=hilite1>ext</SPAN>: '新建', handler: onItemClick},
- {t<SPAN class=hilite1>ext</SPAN>: '保存', handler: onItemClick},
- {t<SPAN class=hilite1>ext</SPAN>: '加载', handler: onItemClick}
- ]}}),
- new <SPAN class=hilite1>Ext</SPAN>.Toolbar.MenuButton({
- t<SPAN class=hilite1>ext</SPAN>: '编辑',
- cls: 'x-btn-t<SPAN class=hilite1>ext</SPAN>-icon blist',
- menu : {items: [
- {t<SPAN class=hilite1>ext</SPAN>: '复制', handler: onItemClick},
- {t<SPAN class=hilite1>ext</SPAN>: '粘贴', handler: onItemClick}
- ]}})
- );
- var root = new <SPAN class=hilite1>Ext</SPAN>.tree.TreeNode({
- t<SPAN class=hilite1>ext</SPAN>: '文件夹',
- allowDrag:false,
- allowDrop:false
- });
- root.appendChild(
- new <SPAN class=hilite1>Ext</SPAN>.tree.TreeNode({t<SPAN class=hilite1>ext</SPAN>:'收件箱',allowDrag:false}),
- new <SPAN class=hilite1>Ext</SPAN>.tree.TreeNode({t<SPAN class=hilite1>ext</SPAN>:'发件箱',allowDrag:false}),
- new <SPAN class=hilite1>Ext</SPAN>.tree.TreeNode({t<SPAN class=hilite1>ext</SPAN>:'联系人',allowDrag:false}),
- new <SPAN class=hilite1>Ext</SPAN>.tree.TreeNode({t<SPAN class=hilite1>ext</SPAN>:'已删除的邮件',allowDrag:false})
- );
- var myData = [
- ['张三','测试','2006-1-1'],
- ['李四','测试一','2006-5-6'],
- ['王五','测试二','2007-12-1'],
- ['刘六','测试三','2006-12-1']
- ];
- var ds = new <SPAN class=hilite1>Ext</SPAN>.data.Store({
- proxy: new <SPAN class=hilite1>Ext</SPAN>.data.MemoryProxy(myData),
- reader: new <SPAN class=hilite1>Ext</SPAN>.data.ArrayReader({}, [
- {name:'sender'},
- {name:'title'},
- {name:'sendtime'}
- ])
- });
- ds.load();
- var colModel = new <SPAN class=hilite1>Ext</SPAN>.grid.ColumnModel([
- {header:'发送人',width:100,sortable:true,dataIndex:'sender'},
- {id:'title',header:'标题', width:100,sortable:true,dataIndex:'title'},
- {header:'发送时间',width:75,sortable:true,dataIndex:'sendtime'}
- ]);
- var viewport = new <SPAN class=hilite1>Ext</SPAN>.Viewport({
- layout:'border',
- items:[
- new <SPAN class=hilite1>Ext</SPAN>.BoxComponent({
- region:'north',
- el:'north-div',
- tbar:tb,
- height:26
- }),
- new <SPAN class=hilite1>Ext</SPAN>.tree.TreePanel({
- region:'west',
- contentEl:'west-div',
- title:'树列表',
- split:true,
- width: 200,
- minSize: 175,
- maxSize: 400,
- collapsible: true,
- margins:'0 0 0 0',
- root:root
- }),
- {
- region:'center',
- layout:'border',
- items:[
- new <SPAN class=hilite1>Ext</SPAN>.grid.GridPanel({
- region:'center',
- el:'center-center',
- title:'条目列表',
- ds: ds,
- cm: colModel,
- autoScroll: true
- }),
- {
- region:'south',
- contentEl:'center-south',
- title:'内容',
- split:true,
- collapsible:true,
- titlebar:true,
- height:200,
- minSize: 100,
- maxSize:400,
- collapsedTitle:'内容'
- }
- ]
- },
- new <SPAN class=hilite1>Ext</SPAN>.BoxComponent({
- region:'south',
- el:'south-div',
- height:24
- })
- ]
- });
- root.expand()
- function onItemClick(item){
- alert(item.t<SPAN class=hilite1>ext</SPAN>);
- }
- })