博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ext DeskTop的使用方法简易教程及相关例子Demo(转)
阅读量:6973 次
发布时间:2019-06-27

本文共 3752 字,大约阅读时间需要 12 分钟。

Ext DeskTop的使用方法简易教程及相关例子Demo(转)

2010-12-31 10:11:15 阅读196 评论0   字号:大中小 订阅

首先为了浏览器兼容问题 可以把网页头的文档类型定义<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">去掉。

第一步当然是导入js和css,官方的例子是这样导入的

HTML语言:
<link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="css/desktop.css" />
<script type="text/javascript" src="http://www.cnblogs.com/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://www.cnblogs.com/ext-all-debug.js"></script>
<script type="text/javascript" src="js/StartMenu.js"></script>
<script type="text/javascript" src="js/TaskBar.js"></script>
<script type="text/javascript" src="js/Desktop.js"></script>
<script type="text/javascript" src="js/App.js"></script>
<script type="text/javascript" src="js/Module.js"></script>
<script type="text/javascript" src="sample.js"></script><!-例子代码,以后会在这个文件的基础上扩展->
 

页面的body里就放一下代码

 

HTML语言:
<body scroll="no">
<div id="x-desktop">
    <a href="http://extjs.com" target="_blank" style="margin:5px; float:right;"><img src="images/powered.gif" /></a>
    <dl id="x-shortcuts"><!-这就是一些桌面图标->
        <dt id="grid-win-shortcut"><!-这个id和后台命名对应->
            <a href="#"><img src="images/s.gif" />
            <div>Grid Window</div></a>
        </dt>
        <dt id="acc-win-shortcut">
            <a href="#"><img src="images/s.gif" />
            <div>Accordion Window</div></a>
        </dt>
    </dl>
</div>
<div id="ux-taskbar"><!-开始菜单->
    <div id="ux-taskbar-start"></div>
    <div id="ux-taskbuttons-panel"></div>
    <div class="x-clear"></div>
</div>
</body> 

简单看看sample.js里面有什么

 

JavaScript语言:
MyDesktop = new Ext.app.App({
    init :function(){
        Ext.QuickTips.init();
    },
    getModules : function(){
        return [
            new MyDesktop.GridWindow(),
            new MyDesktop.TabWindow(),
            new MyDesktop.AccordionWindow(),
            new MyDesktop.BogusMenuModule(),
            new MyDesktop.BogusModule()
        ];
    },
    // 开始菜单的配置,把Start 改成开始 要修改TaskBar.js的内容
    getStartConfig : function(){
        return {
            //开始菜单的标题
            title: 'Jack Slocum',
            //标题前的图片样式
            iconCls: 'user',
            //开始菜单侧边的一些配置,结合例子自己看可以加handler指定相关方法
            toolItems: [{
                text:'Settings',
                iconCls:'settings',
                scope:this
            },'-',{
                text:'Logout',
                iconCls:'logout',
                scope:this
            }]
        };
    }
});
MyDesktop.GridWindow = Ext.extend(Ext.app.Module, {
    //body中指定的id编号
    id:'grid-win',
    init : function(){
        this.launcher = {
            //窗体的名称
            text: 'Grid Window',
            //窗体的图片样式
            iconCls:'icon-grid',
            //创建窗体的方法,
            handler : this.createWindow,
            scope: this
        }
    },
    createWindow : function(){
        //获得desktop对象
        var desktop = this.app.getDesktop();
        //获得名称为grid-win的窗体
        var win = desktop.getWindow('grid-win');
        if(!win){//窗体为空,既没有这个窗体就创建它
            //一下就是窗体配置,自己研究一下
            win = desktop.createWindow({
                id: 'grid-win',
                title:'Grid Window',
                width:740,
                height:480,
                iconCls: 'icon-grid',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout: 'fit',
                items:
                    new Ext.grid.GridPanel({
                        border:false,
                        ds: new Ext.data.Store({
                            reader: new Ext.data.ArrayReader({}, [
                               {name: 'company'},
                               {name: 'price', type: 'float'},
                               {name: 'change', type: 'float'},
                               {name: 'pctChange', type: 'float'}
                            ]),
                            data: Ext.grid.dummyData
                        }),
                        cm: new Ext.grid.ColumnModel([
                            new Ext.grid.RowNumberer(),
                            {header: "Company", width: 120, sortable: true, dataIndex: 'company'},
                            {header: "Price", width: 70, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
                            {header: "Change", width: 70, sortable: true, dataIndex: 'change'},
                            {header: "% Change", width: 70, sortable: true, dataIndex: 'pctChange'}
                        ]),
                        viewConfig: {
                            forceFit:true
                        },
                        //autoExpandColumn:'company',
                        tbar:[{
                            text:'Add Something',
                            tooltip:'Add a new row',
                            iconCls:'add'
                        }, '-', {
                            text:'Options',
                            tooltip:'Blah blah blah blaht',
                            iconCls:'option'
                        },'-',{
                            text:'Remove Something',
                            tooltip:'Remove the selected item',
                            iconCls:'remove'
                        }]
                    })
            });
        }
        win.show();//显示窗体
    }
});
//其他就是创建不同格式的窗体
你可能感兴趣的文章
bzoj1212
查看>>
Datawhale编程——队列
查看>>
Bzoj3597: [Scoi2014]方伯伯运椰子
查看>>
LOJ #2985. 「WC2019」I 君的商店
查看>>
CSS 基本知识
查看>>
JSON数据传递
查看>>
用Python将word文件转换成html(转)
查看>>
移动widget开发
查看>>
CentOS 6.8 安装Tomcat7
查看>>
Nginx 502 bad gateway问题的解决方法
查看>>
11. Container With Most Water - Medium
查看>>
解决Android中图片圆角——.9图
查看>>
retain和copy的区别 #import @class 的区别
查看>>
CSS基础语法
查看>>
N皇后问题
查看>>
springboot热部署
查看>>
MySQL学习(五) UNION与UNION ALL
查看>>
爬虫_淘宝(selenium)
查看>>
关于常用的web.xml、applicationContext.xml与springMVC-servlet.xml
查看>>
14、使用csv和excel存储豆瓣top250电影信息
查看>>