右键菜单类 vjsp.ContextMenu
右键菜单类
示例
//所有按钮控件绑定此右键菜单
var menu = new vjsp.ContextMenu({
mode : 'widget.type',
selector : 'button'
} , [
{
name : 'cm1',
text : '菜单1',
icon : 'fa fa-plus',
action : function(evt , target , name){
vjsp.alert('菜单1');
}
},
{
name : 'cmdivider',
divider : true
},
{
name : 'cm2',
text : '菜单2',
icon : 'fa fa-file-archive-o',
subMenu : [{
name : 'cm3',
text : '菜单3',
action : function(evt , target , name){
vjsp.alert('菜单3');
}
}]
}
]
);
属性
Name | Type | Description |
---|---|---|
ops | Object | 查看ops配置说明 |
menuData | Array.<Object> | 查看菜单项数据说明 |
ops配置
Name | Type | Attributes | Description |
---|---|---|---|
mode | String | 模式dom : dom模式 selector为css选择器widget : 控件模式 selector无效 绑定所有控件widget.type :控件类型模式 selector为控件类型 逗号分隔widget.name :控件名称模式 selector为控件name 逗号分隔 | |
id | String | <optional> | 菜单ID |
selector | String | 选择器 参考mode |
menuData
Name | Type | Attributes | Description |
---|---|---|---|
name | String | 菜单项名称 | |
text | String | <optional> | 菜单项文本 |
icon | String | <optional> | 菜单项图标 |
action | function | <optional> | 菜单项回调函数 , 回调函数有3个参数evt : event对象target :触发对象 dom模式为dom对象 widget模式为控件实例对象name :菜单项name |
subMenu | Array.<Object> | <optional> | 子菜单项数据 |
divider | Boolean | <optional> | 是否为分割线 |
事件
隐藏菜单
hide()
隐藏一个菜单项
hideItem(itemName)
参数:
Name | Type | Description |
---|---|---|
itemName | String | 菜单项name |
显示一个菜单项
showItem(itemName)
参数:
Name | Type | Description |
---|---|---|
itemName | String | 菜单项name |
显示前事件
onBeforeShow(callback)
可以通过this.returnValue=false
禁止显示
参数:
Name | Type | Description |
---|---|---|
callback | function | 回调函数 参数同action |
隐藏所有菜单
(static).hideAllMenu()