Extjs之Extjs工具栏和菜单栏

</pre><pre name="code" class="javascript">Ext.onReady(function() {

			var menu = new Ext.menu.Menu();
			menu.add({
						text : 'Button 1',
						menu : [{
									text : '111'
								}, {
									text : '222'
								}, {
									text : '333'
								}]
					});
			menu.add({
						text : 'Button 2',
						menu : [{
									text : '111'
								}, {
									text : '222'
								}, {
									text : '333'
								}]
					});
			menu.add({
						text : '字号',
						menu : [new Ext.menu.CheckItem({
											text : '1号',
											checked : true,
											group : 'single'
										}), new Ext.menu.CheckItem({
											text : '2号',
											group : 'single'
										}), new Ext.menu.CheckItem({
											text : '3号',
											group : 'single'
										})]
					});

			menu.add({
						text : '字体',
						menu : [new Ext.menu.CheckItem({
											text : '加粗',
											checked : true
										}), new Ext.menu.CheckItem({
											text : '斜体'
										}), new Ext.menu.CheckItem({
											text : '渐变'
										})]
					});

			var btn1 = new Ext.Button({
						text : "文件",
						cls : 'x-btn-text-icon',
						menu : [{
									text : "打开"
								}, {
									text : "保存"
								}, {
									text : "删除"
								}, {
									text : "关闭"
								}, {
									text : "退出"
								}]
					});
			var btn2 = new Ext.Button({
						text : "编辑",
						cls : 'x-btn-text-icon',
						menu : [{
									text : "复制"
								}, {
									text : "拷贝"
								}, '-', {
									text : "查找"
								}, {
									text : "替换"
								}]
					});
			var btn = new Ext.Button({
                        text : "其它",
                        cls : 'x-btn-text-icon',
                        menu : [{
                                    text : "选择日期",
                                    menu : new Ext.menu.DateMenu({
                                       handler:function(dp, date){
                                           Ext.Msg.alert('选择日期', '选择的日期为' + date.format('Y年m月d日'));
                                       }
                                    })
                                }, {
                                    text : "选择颜色",
                                    menu : new Ext.menu.ColorMenu()
                                }]
                    });
					
			var toolbar = new Ext.Toolbar({
						width : 300,
						height : 200,
						items : [btn1, btn2, btn],
						renderTo : Ext.getBody()
					});
			
			var showMenuBar = Ext.get("showMenuBar");
			showMenuBar.on("click", function() {
						menu.show(showMenuBar);
					});
		});


右键弹出菜单

Ext.onReady(function(){
    var menu1 = new Ext.menu.Menu({
        items:[{text:'新1'},{text:'新2'},{text:'新3'}]
    });
    
    var menu2 = new Ext.menu.Menu({
        items:[{text:'新2'},{text:'新2'},{text:'新3'}]
    });
    
    var menu3 = new Ext.menu.Menu({
        items:[{text:'新1'},{text:'新2'},{text:'新3'}]
    });
    
        var menu4 = new Ext.menu.Menu({
        items:[{text:'新1'},{text:'新2'},{text:'新3'}]
    });
	
	var context= new Ext.menu.Menu({
	   items:[{text:'111',menu:menu1},{text:'222',menu:menu2},{text:'333',menu:menu3}]
	});
	
	Ext.get(document).on('contextmenu', function(e){
	   e.preventDefault(); // 取消浏览器对右键的默认操作
	   context.showAt(e.getXY());
	})
});



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值