今天要写extjs导航菜单,查了些资料基本没有满意的,实在是感觉太缺少这方面的资料了,夜里加班偷闲自己动手写了,好了不废话了,看代码。
结果视图如下:
[img]http://dl.iteye.com/upload/attachment/0071/2220/de595547-b618-3b30-bc9c-9d59550df59b.jpg[/img]
附上源代码。
/*by heartneo*/
Ext.onReady(function(){
createPanel();
});
function createPanel(){
filterPanel = Ext.create('Ext.panel.Panel', {//定义panel
width: 300,
title: 'menu',
renderTo: 'menu',
tbar: Ext.create('Ext.toolbar.Toolbar', {//定义toolbar
items: [
{
id: 'options',
xtype:'splitbutton',//定义splitbutton,可以显示下拉菜单
text: 'Options',
menu: {
items: [//定义2个menu
{text: 'Item 1', handler: function(){ window.location = "http://heartneo.iteye.com" }},
{text: 'Item 2', handler: function(){ Ext.MessageBox.alert('heartneo',' -- by heartneo -- '); }}
]
},
listeners : {//监听事件
'mouseover' : function() {//鼠标经过按钮时,显示菜单
Ext.getCmp('options').showMenu();
},
'mouseout' : function() {//鼠标移出时,延迟隐藏菜单
var task = new Ext.util.DelayedTask(function(){//定义延迟任务
Ext.getCmp('options').hideMenu();//
});
task.delay(1500); //1.5秒后隐藏菜单
}
}
}
]
})
});
}
结果视图如下:
[img]http://dl.iteye.com/upload/attachment/0071/2220/de595547-b618-3b30-bc9c-9d59550df59b.jpg[/img]
附上源代码。