`
chenxueyong
  • 浏览: 342130 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

ext的学习笔记4-menu

阅读更多
MENU的使用
/*
* Ext JS Library 1.0
* Copyright(c) 2006-2007, Ext JS, LLC.
* licensing@extjs.com
*
* http://www.extjs.com/license
*/

Ext.onReady(function(){
     Ext.QuickTips.init();

     // Menus can be prebuilt and passed by reference
     var dateMenu = new Ext.menu.DateMenu({                                                         //Menu的引用函数
         handler : function(dp, date){
             Ext.example.msg('Date Selected', 'You chose {0}.', date.format('M j, Y'));
         }
     });

     // Menus can be prebuilt and passed by reference
     var colorMenu = new Ext.menu.ColorMenu({
         handler : function(cm, color){
             Ext.example.msg('Color Selected', 'You chose {0}.', color);
         }
     });

     var menu = new Ext.menu.Menu({                                                                 //创建一个菜单引用
         id: 'mainMenu',
         items: [
             new Ext.menu.CheckItem({
                 text: 'I like Ext',
                 checked: true,
                 checkHandler: onItemCheck
             }),
             new Ext.menu.CheckItem({
                 text: 'Ext for jQuery',
                 checked: true,
                 checkHandler: onItemCheck
             }),
             new Ext.menu.CheckItem({
                 text: 'I donated!',
                 checked:false,
                 checkHandler: onItemCheck
             }), '-', {
                 text: 'Radio Options',
                 menu: {         // <-- submenu by nested config object
                     items: [
                         // stick any markup in a menu
                         '<b class="menu-title">Choose a Theme</b>',
                         new Ext.menu.CheckItem({
                             text: 'Aero Glass',
                             checked: true,
                             group: 'theme',
                             checkHandler: onItemCheck
                         }),
                         new Ext.menu.CheckItem({
                             text: 'Vista Black',
                             group: 'theme',
                             checkHandler: onItemCheck
                         }),
                         new Ext.menu.CheckItem({
                             text: 'Gray Theme',
                             group: 'theme',
                             checkHandler: onItemCheck
                         }),
                         new Ext.menu.CheckItem({
                             text: 'Default Theme',
                             group: 'theme',
                             checkHandler: onItemCheck
                         })
                     ]
                 }
             },{
                 text: 'Choose a Date',
                 cls: 'calendar',
                 menu: dateMenu // <-- submenu by reference                         引用日期子菜单
             },{
                 text: 'Choose a Color',
                 menu: colorMenu // <-- submenu by reference                         引用颜色子菜单
             }
         ]
     });

     var tb = new Ext.Toolbar('toolbar');                                         //创建工具bar 绑定到元素toolbar                                                        
     tb.add({
             cls: 'x-btn-text-icon bmenu', // icon and text class
             text:'Button w/ Menu',
             menu: menu   // assign menu by instance
         },
         new Ext.Toolbar.MenuButton({
             text: 'Split Button',
             handler: onButtonClick,
             tooltip: {text:'This is a QuickTip with autoHide set to false and a title', title:'Tip Title', autoHide:false},
             cls: 'x-btn-text-icon blist',
             // Menus can be built/referenced by using nested menu config objects
             menu : {items: [
                         {text: '<b>Bold</b>', handler: onItemClick},
                         {text: '<i>Italic</i>', handler: onItemClick},
                         {text: '<u>Underline</u>', handler: onItemClick}, '-',{
                         text: 'Pick a Color', handler: onItemClick, menu: {
                         items: [
                                 new Ext.menu.ColorItem({selectHandler:function(cp, color){
                                     Ext.example.msg('Color Selected', 'You chose {0}.', color);
                                 }}), '-',
                                 {text:'More Colors...', handlernItemClick}
                         ]
                     }},
                     {text: 'Extellent!', handler: onItemClick}
                 ]}
         }), '-', {
         text: 'Toggle Me',
         enableToggle: true,
         toggleHandler: onItemToggle,
         pressed: true
     });

     menu.addSeparator();
     // Menus have a rich api for
     // adding and removing elements dynamically
     var item = menu.add({
         text: 'Dynamically added Item'
     });
     // items support full Observable API
     item.on('click', onItemClick);

     // items can easily be looked up
     menu.add({
         text: 'Disabled Item',
         id: 'disableMe'   // <-- Items can also have an id for easy lookup
         // disabled: true    <-- allowed but for sake of example we use long way below
     });
     // access items by id or index
     menu.items.get('disableMe').disable();

     // They can also be referenced by id in or components
     tb.add('-', {
         icon: 'list-items.gif', // icons can also be specified inline
         cls: 'x-btn-icon',
         tooltip: '<b>Quick Tips</b><br/>Icon only button with tooltip'
     }, '-');

     // add a combobox to the toolbar
     var store = new Ext.data.SimpleStore({
         fields: ['abbr', 'state'],
         data : Ext.exampledata.states // from states.js
     });
     var combo = new Ext.form.ComboBox({
         store: store,
         displayField:'state',
         typeAhead: true,
         mode: 'local',
         triggerAction: 'all',
         emptyText:'Select a state...',
         selectOnFocus:true,
         width:135
     });
     tb.addField(combo);

     // functions to display feedback
     function onButtonClick(btn){
         Ext.example.msg('Button Click','You clicked the "{0}" button.', btn.text);
     }

     function onItemClick(item){
         Ext.example.msg('Menu Click', 'You clicked the "{0}" menu item.', item.text);
     }

     function onItemCheck(item, checked){
         Ext.example.msg('Item Check', 'You {1} the "{0}" menu item.', item.text, checked ? 'checked' : 'unchecked');
     }

     function onItemToggle(item, pressed){
         Ext.example.msg('Button Toggled', 'Button "{0}" was toggled to {1}.', item.text, pressed);
     }
});
分享到:
评论

相关推荐

    ext-2.0 ext-2.0 ext-2.0 ext-2.0 ext-2.0

    ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0ext-2.0

    openwrt-23.05.2-x86-64-generic-ext4-combined-efi.img.gz

    openwrt软路由

    ext4magic-0.3.2-3.10.x86_64.rpm

    ext4magic-0.3.2-3.10.x86_64.rpm

    bcprov-ext-jdk16-1.45.jar

    bcprov-ext-jdk16-1.45.jar资源包 ,在进行JAVA的ECC椭圆算法调用时,需要用到的jar包

    ext-3.3.1 ext-3.3.1

    ext-3.3.1ext-3.3.1ext-3.3.1ext-3.3.1ext-3.3.1ext-3.3.1

    前端开源库-style-ext-html-webpack-plugin

    其中,“style-ext-html-webpack-plugin”是一个特别值得关注的插件,它专门针对HTML文件的内联样式进行了优化,以提高页面加载速度和用户体验。 **一、插件概述** “style-ext-html-webpack-plugin”是针对...

    ext4-exactor.zip

    在Android系统中,EXT4文件系统是广泛使用的主文件系统,用于存储应用程序、系统文件和其他数据。EXT4-extractor是一个专为Android设计的工具,它能够帮助开发者和故障排除人员解析EXT4格式的镜像文件,将其转换为一...

    ext-ms-win-gdi-desktop-l1-1-0.dll

    ext-ms-win-gdi-desktop-l1-1-0.dll 用于解决这个dll文件丢失问题,下载后将此文件放置在相关文件根目录下,即可解决丢失问题

    EXT学习笔记-项目应用实践

    这篇EXT学习笔记主要涵盖了EXTJS中面向对象编程的一些关键概念和实践,包括命名空间、类定义、构造函数、属性与方法的访问控制(私有和公有)、静态属性与方法以及继承机制。 1. **命名空间**:在EXTJS中,命名空间...

    Gwt-ext学习笔记之基础篇

    ### Gwt-ext学习笔记之基础篇 #### 一、安装CypalStudio工具 为了能够开始Gwt-ext的学习之旅,首先需要确保开发环境已经搭建好。CypalStudio是一款非常实用的工具,它能帮助开发者更高效地进行GWT项目的开发。 1....

    ext-base ext-4.1.1a-commercial

    ext-base ext-4.1.1a-commercial

    ext+jsp分页---好不好,大家说了算。下载不扣分,回帖加1分,欢迎下载,童叟无欺。

    ext+jsp分页---好不好,大家说了算。下载不扣分,回帖加1分,欢迎下载,童叟无欺。ext+jsp分页---好不好,大家说了算。下载不扣分,回帖加1分,欢迎下载,童叟无欺。ext+jsp分页---好不好,大家说了算。下载不扣分,...

    EXT-4.0.2a-gpl.zip

    EXT-4.0.2a-gpl.zip的源代码可以供开发者研究EXT4的内部工作原理,或者根据GPL协议进行修改和分发。源代码的编译和安装通常涉及以下步骤: 1. 解压下载的zip文件:`unzip EXT-4.0.2a-gpl.zip` 2. 进入源代码目录:`...

    Python库 | nnabla_ext_cuda100-1.21.0-cp36-cp36m-win_amd64.whl

    总的来说,nnabla_ext_cuda100-1.21.0-cp36-cp36m-win_amd64.whl是一个针对Python 3.6和CUDA 100的nnabla库版本,专为64位Windows系统上的AMD64架构设计,提供GPU加速的深度学习计算。通过这个库,开发者可以利用GPU...

    3------通过实例学习------Ext.js------.pdf

    8. **bootstrap.js**:Ext.js的库引导文件,可以根据参数自动选择加载`ext-all.js`或`ext-all-debug.js`。 9. **ext-all.js**:Ext.js的核心库,用于生产环境。 10. **ext-all-debug.js**:调试版本的核心库,包含...

    (转载)GWT -EXT学习笔记-基础

    3. 在项目的`public`目录下新建`js`文件夹,并将`ext-2.1`目录下的`adapter`、`resources`以及`ext-all.js`、`ext-core.js`文件复制到`js`文件夹下。 **步骤二:修改HTML宿主页面和模块配置文件** 1. 修改`...

    EXT学习札记--京华志

    - 需要先加载`ext-base.js`文件,再加载`ext-all.js`文件,这是因为前者包含了后者运行所需的基础功能。 - 在某些情况下,还需要设置页面的字符集编码,例如`&lt;meta http-equiv="Content-Type" content="text/html;...

    spketdwcs-ext-2.1.mxp

    spketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-ext-2.1.mxpspketdwcs-...

Global site tag (gtag.js) - Google Analytics