Latest web development tutorials
×

jQuery EasyUI Tutorial

jQuery EasyUI Tutorial jQuery EasyUI Introduction

jEasyUI application

jEasyUI Create a CRUD application jEasyUI Create a CRUD data grid jEasyUI Form CRUD application jEasyUI Create an RSS reader

jEasyUI Drag and drop

jEasyUI Basic drag and drop jEasyUI Create a drag-and-drop shopping cart jEasyUI Create a school curriculum

jEasyUI Menus and buttons

jEasyUI Create a simple menu jEasyUI Create a link button jEasyUI Create a menu button jEasyUI Create a split button

jEasyUI layout

jEasyUI Create a border layout jEasyUI Create a complex layout jEasyUI Creates a fold panel jEasyUI Create a tab page jEasyUI Dynamically add a tab jEasyUI Add the AutoPlay tab jEasyUI Create the XP style left panel

jEasyUI Data grid

jEasyUI Convert HTML tables to data grids jEasyUI Get the selected row data jEasyUI Add the query function jEasyUI Add a toolbar jEasyUI Create complex toolbars jEasyUI Sets the frozen column jEasyUI Dynamically change columns jEasyUI Format the column jEasyUI Set sort jEasyUI Custom sorting jEasyUI Create a column combination jEasyUI Add a check box jEasyUI Custom tab jEasyUI Enable in-line editing jEasyUI Extension editor jEasyUI Column operation jEasyUI Merge Cells jEasyUI Create a custom view jEasyUI Create a footer summary jEasyUI Condition Sets the line background color jEasyUI Create an attribute grid jEasyUI The extended line shows the details jEasyUI Create a subgrid jEasyUI Display massive data jEasyUI Add a paging component

jEasyUI window

jEasyUI Create a simple window jEasyUI Customize the Window Toolbar jEasyUI Window and layout jEasyUI Create a dialog box jEasyUI Customize the dialog box

jEasyUI Tree menu

jEasyUI Use the markup to create a tree menu jEasyUI Create an asynchronous tree menu jEasyUI Tree menu to add nodes jEasyUI Create a tree menu with check boxes jEasyUI Tree menu drag and drop control jEasyUI The Tree menu loads the parent / child nodes jEasyUI Create the base tree grid jEasyUI Create a complex tree grid jEasyUI Dynamic loading of tree jEasyUI The tree grid adds pagination jEasyUI Tree-lazy lazy-loading node

jEasyUI Form

jEasyUI Create an asynchronous submission form jEasyUI Form validation jEasyUI Create a tree drop-down box jEasyUI Format the drop-down box jEasyUI Filter down the data grid

jEasyUI Reference Manual

jQuery EasyUI Plugin jQuery EasyUI Extended

jQuery EasyUI menu and button widget - Menu Menu

jQuery EasyUI plugin jQuery EasyUI plugin

By $ .fn.menu.defaults override the default defaults.

Menu (Menu) is usually used in the context menu. It is to create a menu of other components (such as: menubutton, splitbutton) of the basic components. It can also navigate and execute commands.

usage

Create menu (Menu)

By marking the Create menu (menu) should be added 'easyui-menu' class to the <div> tag. Each menu item (menu item) tags created by the <div>. We can add 'iconCls' attribute to a menu item (menu item), to define the left-hand menu item (menu item) a display icon. Add 'menu-sep' class to the menu item (menu item) will produce a menu (menu) delimiter.

<Div id = "mm" class = "easyui-menu" style = "width: 120px;">
    <Div> New </ div>
    <Div>
		<Span> Open </ span>
		<Div style = "width: 150px;">
			<Div> <b> Word </ b> </ div>
			<Div> Excel </ div>
			<Div> PowerPoint </ div>
		</ Div>
    </ Div>
    <Div data-options = "iconCls: 'icon-save'"> Save </ div>
    <Div class = "menu-sep"> </ div>
    <Div> Exit </ div>
</ Div>

Programmatically create a menu (menu) and listeners 'onClick' event.

$ ( '# Mm'). Menu ({
    onClick: function (item) {
		// ...
    }
});

Display menu (Menu)

When the menu (menu) is created, it is hiding invisible. Call the 'show' method to display the menu (menu).

$ ( '# Mm'). Menu ( 'show', {
    left: 200,
    top: 100
});

Menu Item

Menu item (menu item) represents a separate item in the menu display. It contains the following properties:

名称 类型 描述 默认值
id string 菜单项(menu item)的 id 属性。
text string 项目文本。
iconCls string 在项目左边显示一个 16x16 图标的 CSS class。
href string 当点击菜单项(menu item)时设置页面位置。
disabled boolean 定义是否禁用菜单项(menu item)。 false
onclick function 当点击菜单项(menu item)时被调用的函数。

Menu Properties

名称 类型 描述 默认值
zIndex number 菜单(Menu)的 z-index 样式,从它开始增加。 110000
left number 菜单(Menu)的左边位置。 0
top number 菜单(Menu)的顶部位置。 0
minWidth number 菜单(Menu)的最小宽度。该属性自版本 1.3.2 起可用。 120
hideOnUnhover boolean 如果设置为 true,当鼠标离开它时自动隐藏菜单(menu)。该属性自版本 1.3.5 起可用。 true

Event Menu

名称 参数 描述
onShow none 当菜单(menu)显示之后触发。
onHide none 当菜单(menu)隐藏之后触发。
onClick item 当点击菜单项(menu item)时触发。下面的实例演示如何处理所有菜单项点击:
<div class="easyui-menu" data-options="onClick:menuHandler" style="width:120px;">
	<div data-options="name:'new'">New</div>
	<div data-options="name:'save',iconCls:'icon-save'">Save</div>
	<div data-options="name:'print',iconCls:'icon-print'">Print</div>
	<div class="menu-sep"></div>
	<div data-options="name:'exit'">Exit</div>
</div>
<script type="text/javascript">
	function menuHandler(item){
		alert(item.name)
	}
</script>

Menu Method

名称 参数 描述
options none 返回选项(options)对象。
show pos 在指定的位置显示菜单(menu)。
pos 参数有两个属性:
left:新的左边位置。
top:新的顶部位置。
hide none 隐藏菜单(menu)。
destroy none 销毁菜单(menu)。
getItem itemEl 获取包含 'target' 属性(指示项目 DOM 元素)的菜单项(menu item)属性。下面的实例演示如何通过 id 获取指定的项目:
<div id="mm" class="easyui-menu" style="width:120px">
	<div>New</div>
	<div id="m-open">Open</div>
	<div>Save</div>
</div>

var itemEl = $('#m-open')[0];  // the menu item element
var item = $('#mm').menu('getItem', itemEl);
console.log(item);
setText param 给指定的菜单项(menu item)设置文本。'param' 参数包含两个属性:
target:DOM 对象,被设定的菜单项(menu item)。
text:string,新的文本值。

代码实例:
var item = $('#mm').menu('findItem', 'Save');
$('#mm').menu('setText', {
	target: item.target,
	text: 'Saving'
});
setIcon param 给指定的菜单项(menu item)设置图标。'param' 参数包含两个属性:
target:DOM 对象,即菜单项(menu item)。
iconCls:新图标的 CSS class。

代码实例:
$('#mm').menu('setIcon', {
	target: $('#m-open')[0],
	iconCls: 'icon-closed'
});
findItem text 找到指定的菜单项(menu item),返回对象与 getItem 方法相同。
代码实例:
// find 'Open' item and disable it
var item = $('#mm').menu('findItem', 'Open');
$('#mm').menu('disableItem', item.target);
appendItem options 追加一个新的菜单项(menu item),'param' 参数指示新的项目属性。默认情况下,新增的项目将作为顶级菜单项(menu item)。如需追加一个子菜单项,需设置 'parent' 属性,用来指示已经有子项目的父项目元素。
代码实例:
// append a top menu item
$('#mm').menu('appendItem', {
	text: 'New Item',
	iconCls: 'icon-ok',
	onclick: function(){alert('New Item')}
});
// append a menu separator
$('#mm').menu('appendItem', {
	separator: true
});
// append a sub menu item
var item = $('#mm').menu('findItem', 'Open');  // find 'Open' item
$('#mm').menu('appendItem', {
	parent: item.target,  // the parent item element
	text: 'Open Excel',
	iconCls: 'icon-excel',
	onclick: function(){alert('Open Excel')}
});
removeItem itemEl 移除指定的菜单项(menu item)。
enableItem itemEl 启用菜单项(menu item)。
disableItem itemEl 禁用菜单项(menu item)。

jQuery EasyUI plugin jQuery EasyUI plugin