初試jQuery EasyUI 使用介紹
jQuery EasyUI是一組基于jQuery的UI插件集合,而jQuery EasyUI的目標(biāo)就是幫助web開(kāi)發(fā)者更輕松的打造出功能豐富并且美觀的UI界面。開(kāi)發(fā)者不需要編寫復(fù)雜的javascript,也不需要對(duì)css樣式有深入的了解,開(kāi)發(fā)者需要了解的只有一些簡(jiǎn)單的html標(biāo)簽。
jQuery EasyUI為我們提供了大多數(shù)UI控件的使用,如:accordion,combobox,menu,dialog,tabs,tree,window等等。
OK,下面就開(kāi)始我們的初探之旅。
jQuery EasyUI---Accordion
手風(fēng)琴效果,大家應(yīng)該很熟悉。
基本代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Accordion</title>
<script src="../jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../jquery.easyui.min.js" type="text/javascript"></script>
<link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../themes/icon.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"></script>
</head>
<body>
<div style="overflow:auto;width:600px;height:300px;padding:10px;border:1px solid #ccc;">
<div id="aa" class="easyui-accordion" fit="true" style="width:300px;height:200px;">
<div title="Title1" style="overflow:auto;padding:10px;">
<h3>Accordion1</h3>
</div>
<div title="Title2" style="padding:10px;">
<h3>Accordion2</h3>
</div>
<div title="Title3">
<h3>Accordion3</h3>
</div>
</div>
</div>
</body>
</html>
代碼非常簡(jiǎn)單,只需要簡(jiǎn)單的html就可以實(shí)現(xiàn)。這里最重要的就是首先要引用jquery-1.4.2.min.js和jquery.easyui.min.js。
效果:

由于只是簡(jiǎn)單的html,所以我們可以通過(guò)js輕松的對(duì)Accordion進(jìn)行操控,控制大小,位置等等。
jQuery EasyUI---DataGrid
從名字就可以知道這是個(gè)數(shù)據(jù)的綁定和顯示控件。
基本代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DataGrid</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="../jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../jquery.easyui.min.js" type="text/javascript"></script>
<link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../themes/icon.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function() {
$('#test').datagrid({
title: 'jQuery EasyUI---DataGrid',
iconCls: 'icon-save',
width: 500,
height: 350,
nowrap: false,
striped: true,
url: '../Data/datagrid_data.json',
sortName: 'ID',
sortOrder: 'desc',
idField: 'ID',
frozenColumns: [[
{ field: 'ck', checkbox: true },
{ title: 'ID', field: 'ID', width: 80, sortable: true }
]],
columns: [[
{ title: '基本信息', colspan: 2 },
{ field: 'opt', title: '操作', width: 100, align: 'center', rowspan: 2,
formatter: function(value, rec) {
return '<span style="color:red">編輯 刪除</span>';
}
}
], [
{ field: 'name', title: 'Name', width: 120 },
{ field: 'addr', title: 'Address', width: 120, rowspan: 2, sortable: true }
]],
pagination: true,
rownumbers: true,
singleSelect: false,
toolbar: [{
text: '添加',
iconCls: 'icon-add',
handler: function() {
alert('添加數(shù)據(jù)')
}
}, '-', {
text: '保存',
iconCls: 'icon-save',
handler: function() {
alert('保存數(shù)據(jù)')
}
}]
});
});
</script>
</head>
<body>
<table id="test"></table>
</body>
</html>
這里我們從datagrid_data.json中獲取數(shù)據(jù),代碼的編寫風(fēng)格同EXTIS十分相似。ExtJS開(kāi)發(fā)實(shí)踐
效果:
jQuery EasyUI---Dialog
網(wǎng)頁(yè)窗體效果。
基本代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dialog</title>
<script src="../jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../jquery.easyui.min.js" type="text/javascript"></script>
<link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../themes/icon.css" rel="stylesheet" type="text/css" />
<script>
$(function(){
$('#dd').dialog({
toolbar:[{
text:'添加',
iconCls:'icon-add',
handler:function(){
alert('添加數(shù)據(jù)')
}
},'-',{
text:'保存',
iconCls:'icon-save',
handler:function(){
alert('保存數(shù)據(jù)')
}
}],
buttons:[{
text:'提交',
iconCls:'icon-ok',
handler:function(){
alert('提交數(shù)據(jù)');
}
},{
text:'取消',
handler:function(){
$('#dd').dialog('取消');
}
}]
});
});
</script>
</head>
<body>
<div id="dd" style="padding:5px;width:400px;height:200px;">
<p>jQuery EasyUI---Dialog</p>
</div>
</body>
</html>
效果:
jQuery EasyUI---Tabs
無(wú)論是網(wǎng)站還是管理軟件,我們?cè)絹?lái)越多的使用Tabs,EasyUI自然也進(jìn)行了支持。
基本代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tabs</title>
<script src="../jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../jquery.easyui.min.js" type="text/javascript"></script>
<link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../themes/icon.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="tt" class="easyui-tabs" style="width:500px;height:250px;">
<div title="Tab1" style="padding:20px;display:none;">
<h1>Tab1 Content</h1>
</div>
<div title="Tab5" closable="true" style="padding:10px;display:none;">
<div class="easyui-tabs" fit="true" plain="true" style="height:100px;width:300px;">
<div title="Title1">Content 1</div>
<div title="Title2">Content 2</div>
<div title="Title3">Content 3</div>
</div>
</div>
</div>
</body>
</html>
效果:
jQuery EasyUI---Messager
信息提示控件,可以很好的進(jìn)行數(shù)據(jù)的提示,推薦。
基本代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Messager</title>
<script src="../jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../jquery.easyui.min.js" type="text/javascript"></script>
<link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../themes/icon.css" rel="stylesheet" type="text/css" />
<script>
function show1() {
$.messager.show({
title: '提示信息1',
msg: '信息1',
showType: 'show'
});
}
function show2() {
$.messager.show({
title: '提示信息2',
msg: '信息5分鐘后消失.',
timeout: 5000,
showType: 'slide'
});
}
function show3() {
$.messager.show({
title: '漸進(jìn)顯示信息3',
msg: '漸進(jìn)顯示信息3',
timeout: 0,
showType: 'fade'
});
}
</script>
</head>
<body>
<h1>信息提示</h1>
<div>
<a href="javascript:void(0)" onclick="show1()">顯示</a> |
<a href="#" onclick="show2()">滑動(dòng)</a> |
<a href="#" onclick="show3()">漸進(jìn)顯示</a> |
</div>
</body>
</html>
效果:
頁(yè)面左下角信息提示
jQuery EasyUI---ValidateBox
數(shù)據(jù)驗(yàn)證控件,可以很好的對(duì)表單數(shù)據(jù)進(jìn)行驗(yàn)證。
基本代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ValidateBox</title>
<script src="../jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../jquery.easyui.min.js" type="text/javascript"></script>
<link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../themes/icon.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div>
<table>
<tr>
<td>姓名:</td>
<td><input class="easyui-validatebox" required="true" validType="length[1,3]"></td>
</tr>
<tr>
<td>電子郵件:</td>
<td><input class="easyui-validatebox" required="true" validType="email"></td>
</tr>
<tr>
<td>URL:</td>
<td><input class="easyui-validatebox" required="true" validType="url"></td>
</tr>
<tr>
<td>說(shuō)明:</td>
<td><textarea class="easyui-validatebox" required="true" style="height:100px;"></textarea></td>
</tr>
</table>
</div>
</body>
</html>
不需要寫任何函數(shù),只需對(duì)要驗(yàn)證的控件required="true" validType="url"就可以。
效果:
jQuery EasyUI---LayOut
頁(yè)面布局,可以將整個(gè)頁(yè)面劃分成幾個(gè)區(qū)域。類似ExtJS中的Border布局。
基本代碼:
效果:
jQuery EasyUI---換膚
jQuery EasyUI使用了統(tǒng)一的CSS樣式,在修改方面也很是方便:
如圖所示,對(duì)于每一個(gè)控件,都有專有的CSS。相應(yīng)對(duì)其修改就可以,只需簡(jiǎn)單的了解CSS即可。
小結(jié):jQuery EasyUI的體驗(yàn)就到這里,還有一些控件這里沒(méi)有介紹,比如:combobox,splitbutton等等。
官方網(wǎng)站:http://jquery-easyui.wikidot.com/start
下載地址:http://jquery-easyui.wikidot.com/download
本文代碼打包下載
文章作者:高維鵬(Brian)
相關(guān)文章
JQ獲取動(dòng)態(tài)加載的圖片大小的正確方法分享
這篇文章介紹了JQ獲取動(dòng)態(tài)加載的圖片大小的正確方法,有需要的朋友可以參考一下2013-11-11
jQuery實(shí)現(xiàn)簡(jiǎn)單倒計(jì)時(shí)功能的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單倒計(jì)時(shí)功能的方法,涉及jQuery根據(jù)時(shí)間動(dòng)態(tài)操作頁(yè)面元素的相關(guān)技巧,需要的朋友可以參考下2016-07-07
jquery中通過(guò)父級(jí)查找進(jìn)行定位示例
如果想要查找到有icon這個(gè)class的span除了用原始的代碼還可以用父級(jí)查詢的方法進(jìn)行定位,具體的實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助2013-06-06
使用BootStrap和Metroui設(shè)計(jì)的metro風(fēng)格微網(wǎng)站或手機(jī)app界面
今天使用bootstrap和metroui設(shè)計(jì)了一個(gè)metro風(fēng)格的移動(dòng)app或者微信微網(wǎng)站的界面,非常不錯(cuò)具有參考借鑒價(jià)值,感興趣的朋友可以參考下2016-10-10
easyui簡(jiǎn)介_(kāi)動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要介紹了easyui簡(jiǎn)介,詳細(xì)的介紹了什么是easyui和easyui的用法,有興趣的可以了解一下2017-07-07
Jquery多選框互相內(nèi)容交換的實(shí)例代碼
這篇文章介紹了Jquery多選框互相內(nèi)容交換的實(shí)例代碼,有需要的朋友可以參考一下2013-07-07
JQuery統(tǒng)計(jì)input和textarea文字輸入數(shù)量(代碼分享)
本文主要介紹了jQuery實(shí)現(xiàn)統(tǒng)計(jì)輸入文字個(gè)數(shù)的方法,具有一定的參考價(jià)值,需要的朋友一起來(lái)看下吧2016-12-12
用Jquery選擇器計(jì)算table中的某一列某一行的合計(jì)
本節(jié)主要介紹了用Jquery選擇器計(jì)算table中的某一列某一行的合計(jì),需要的朋友可以參考下2014-08-08

