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 layout widget - Tabs tab / tab

jQuery EasyUI plugin jQuery EasyUI plugin

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

The tabs display a collection of panel. It shows only one tab panel at a time. Each tab panel has the header title and some mini button tools, including close button and other customized buttons.

rely

  • panel
  • linkbutton

usage

Create tabs (Tabs)

1. Create a tab by marking (Tabs)

Create tab from the tag (Tabs) easier, we do not need to write any JavaScript code. Remember to add 'easyui-tabs' class to the <div> tag. Each label page board (tab panel) was created by the sub-tag <div>, its usage and the panel (panel) the same.

<Div id = "tt" class = "easyui-tabs" style = "width: 500px; height: 250px;">
    <Div title = "Tab1" style = "padding: 20px; display: none;">
		tab1
    </ Div>
    <Div title = "Tab2" data-options = "closable: true" style = "overflow: auto; padding: 20px; display: none;">
		tab2
    </ Div>
    <Div title = "Tab3" data-options = "iconCls: 'icon-reload', closable: true" style = "padding: 20px; display: none;">
		tab3
    </ Div>
</ Div>

2, programmatically create tabs (Tabs)

We now programmatically create tabs (Tabs), we also catch 'onSelect' event.

$ ( '# Tt'). Tabs ({
    border: false,
    onSelect: function (title) {
		alert (title + 'is selected');
    }
});

Add new tags page plate (tab panel)

Add a new page tag plate (tab panel) through mini tool Mini tool icon (8x8) placed in front of the Close button.

// Add a new tab page plate (tab panel)
$ ( '# Tt'). Tabs ( 'add', {
    title: 'New Tab',
    content: 'Tab Body',
    closable: true,
    tools: [{
		iconCls: 'icon-mini-refresh',
		handler: function () {
			alert ( 'refresh');
		}
    }]
});

Get the selected tab (Tab)

// Get the selected tab page plate (tab panel) and its tabs (tab) objects var pp = $ ( '# tt') tabs ( 'getSelected').;
var tab = pp.panel ( 'options') tab;. // corresponding tabs (tab) Object 

Attributes

名称 类型 描述 默认值
width number 标签页(Tabs)容器的宽度。 auto
height number 标签页(Tabs)容器的高度。 auto
plain boolean 当设置为 true 时,就不用背景容器图片来呈现 tab 条。 false
fit boolean 当设置为 true 时,就设置标签页(Tabs)容器的尺寸以适应它的父容器。 false
border boolean 当设置为 true 时,就显示标签页(Tabs)容器边框。 true
scrollIncrement number 每按一次 tab 滚动按钮,滚动的像素数。 100
scrollDuration number 每一个滚动动画应该持续的毫秒数。 400
tools array,selector 放置在头部的左侧或右侧的工具栏,可能的值:
1、数组,指示工具组,每个工具选项都和链接按钮(Linkbutton)一样。
2、选择器,指示包含工具的 <div>。

代码实例:
通过数组定义工具。
$('#tt').tabs({
	tools:[{
		iconCls:'icon-add',
		handler:function(){
			alert('add')
		}
	},{
		iconCls:'icon-save',
		handler:function(){
			alert('save')
		}
	}]
});
通过已有的 DOM 容器定义工具。
$('#tt').tabs({
	tools:'#tab-tools'
});
<div id="tab-tools">
	<a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-add"></a>
	<a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-save"></a>
</div>
null
toolPosition string 工具栏位置。可能的值:'left'、'right'。该属性自版本 1.3.2 起可用。 right
tabPosition string 标签页(tab)位置。可能的值:'top'、'bottom'、'left'、'right'。该属性自版本 1.3.2 起可用。 top
headerWidth number 标签页(tab)头部宽度,只有当 tabPosition 设置为 'left' 或 'right' 时才有效。该属性自版本 1.3.2 起可用。 150
tabWidth number tab 条的宽度。该属性自版本 1.3.4 起可用。 auto
tabHeight number tab 条的高度。该属性自版本 1.3.4 起可用。 27
selected number 初始化选定的标签页索引。该属性自版本 1.3.5 起可用。 0
showHeader boolean 当设置为 true 时,显示标签页(tab)头部。该属性自版本 1.3.5 起可用。 true

event

名称 参数 描述
onLoad panel 当一个 ajax 标签页面板(tab panel)完成加载远程数据时触发。
onSelect title,index 当用户选择一个标签页面板(tab panel)时触发。
onUnselect title,index 当用户未选择一个标签页面板(tab panel)时触发。该事件自版本 1.3.5 起可用。
onBeforeClose title,index 当一个标签页面板(tab panel)被关闭前触发,返回 false 就取消关闭动作。下面的实例演示如何在关闭标签页面板(tab panel)前显示确认对话框。
$('#tt').tabs({
  onBeforeClose: function(title){
	return confirm('Are you sure you want to close ' + title);
  }
});
// using the async confirm dialog
$('#tt').tabs({
  onBeforeClose: function(title,index){
	var target = this;
	$.messager.confirm('Confirm','Are you sure you want to close '+title,function(r){
		if (r){
			var opts = $(target).tabs('options');
			var bc = opts.onBeforeClose;
			opts.onBeforeClose = function(){};  // allowed to close now
			$(target).tabs('close',index);
			opts.onBeforeClose = bc;  // restore the event function
		}
	});
	return false;	// prevent from closing
  }
});
onClose title,index 当用户关闭一个标签页面板(tab panel)时触发。
onAdd title,index 当一个新的标签页面板(tab panel)被添加时触发。
onUpdate title,index 当一个标签页面板(tab panel)被更新时触发。
onContextMenu e, title,index 当一个标签页面板(tab panel)被右键点击时触发。

method

名称 参数 描述
options none 返回标签页(tabs)选项(options)。
tabs none 返回全部的标签页面板(tab panel)。
resize none 调整标签页(tabs)容器的尺寸并做布局。
add options 添加一个新的标签页面板(tab panel),options 参数是一个配置对象,更多详细信息请参见标签页面板(tab panel)属性。
当添加一个新的标签页面板(tab panel)时,它将被选中。
如需添加一个未选中的标签页面板(tab panel),请记得设置 'selected' 属性为 false。
// add a unselected tab panel
$('#tt').tabs('add',{
	title: 'new tab',
	selected: false
	//...
});
close which 关闭一个标签页面板(tab panel),'which' 参数可以是要被关闭的标签页面板(tab panel)的标题(title)或索引(index)。
getTab which 获取指定的标签页面板(tab panel),'which' 参数可以是标签页面板(tab panel)的标题(title)或索引(index)。
getTabIndex tab 获取指定的标签页面板(tab panel)索引。
getSelected none 获取选中的标签页面板(tab panel)。下面的实例演示如何获取选中的标签页面板(tab panel)的索引。
var tab = $('#tt').tabs('getSelected');
var index = $('#tt').tabs('getTabIndex',tab);
alert(index);
select which 选择一个标签页面板(tab panel),'which' 参数可以是标签页面板(tab panel)的标题(title)或索引(index)。
unselect which 选择一个标签页面板(tab panel),'which' 参数可以是标签页面板(tab panel)的标题(title)或索引(index)。该方法自版本 1.3.5 起可用。
showHeader none 显示标签页(tabs)头部。该方法自版本 1.3.5 起可用。
hideHeader none 隐藏标签页(tabs)头部。该方法自版本 1.3.5 起可用。
exists which 指示指定的面板是否已存在,'which' 参数可以是标签页面板(tab panel)的标题(title)或索引(index)。
update param 更新指定的标签页面板(tab panel),param 参数包含两个属性:
tab:被更新的标签页面板(tab panel)。
options:面板(panel)的选项(options)。

代码实例:
// update the selected panel with new title and content
var tab = $('#tt').tabs('getSelected');  // get selected panel
$('#tt').tabs('update', {
	tab: tab,
	options: {
		title: 'New Title',
		href: 'get_content.php'  // the new content URL
	}
});

// call 'refresh' method for tab panel to update its content
var tab = $('#tt').tabs('getSelected');  // get selected panel
tab.panel('refresh', 'get_content.php');
enableTab which 启用指定的标签页面板(tab panel),'which' 参数可以是标签页面板(tab panel)的标题(title)或索引(index)。该方法自版本 1.3 起可用。

代码实例:
$('#tt').tabs('enableTab', 1);	// enable the second tab panel
$('#tt').tabs('enableTab', 'Tab2');	enable the tab panel that has 'Tab2' title
disableTab which 禁用指定的标签页面板(tab panel),'which' 参数可以是标签页面板(tab panel)的标题(title)或索引(index)。该方法自版本 1.3 起可用。

代码实例:
$('#tt').tabs('disableTab', 1);	// disable the second tab panel.
scrollBy deltaX 通过指定的像素数滚动标签页(tab)头部,负值表示滚动到右边,正值表示滚动到左边。该方法自版本 1.3.2 起可用。

代码实例:
// scroll the tab header to left
$('#tt').tabs('scroll', 10);

Tags page plate (Tab Panel)

Tag board page (tab panel) property is defined in the panel (panel) component, the following are some common attributes.

名称 类型 描述 默认值
id string 标签页面板(tab panel)的 id 属性。 null
title string 标签页面板(tab panel)的标题文字。
content string 标签页面板(tab panel)的内容。
href string 加载远程内容来填充标签页面板(tab panel)的 URL。 null
cache boolean 当设置为 true 时,在设定了有效的 href 特性时缓存这个标签页面板(tab panel)。 true
iconCls string 显示在标签页面板(tab panel)标题上的图标的 CSS class。 null
width number 标签页面板(tab panel)的宽度。 auto
height number 标签页面板(tab panel)的高度。 auto
collapsible boolean 当设置为 true 时,允许标签页面板(tab panel)可折叠。 false

Some additional attributes.

名称 类型 描述 默认值
closable boolean 当设置为 true 时,标签页面板(tab panel)将显示一个关闭按钮,点击它就能关闭这个标签页面板(tab panel)。 false
selected boolean 当设置为 true 时,标签页面板(tab panel)将被选中。 false

jQuery EasyUI plugin jQuery EasyUI plugin