jquery easyui中文培训文档

455 阅读16分钟

目  录

1.... Accordion (可折叠标签) ....................................................................................... 2

1.1          实例........................................................................................................... 2

1.2          参数........................................................................................................... 3

2.... DateBox (日期框) ................................................................................................. 4

2.1          实例........................................................................................................... 4

2.2          参数........................................................................................................... 6

2.3          事件........................................................................................................... 6

2.4          方法........................................................................................................... 6

3.... ComboBox( 组合框 ) .................................................................................................. 7

3.1          实例........................................................................................................... 7

3.2          参数........................................................................................................... 9

3.3          事件........................................................................................................... 9

3.4          方法........................................................................................................... 9

4.... Dialog (对话框) .................................................................................................. 10

4.1          实例......................................................................................................... 10

4.2          参数......................................................................................................... 12

4.3          事件......................................................................................................... 12

4.4          方法......................................................................................................... 12

5.... Messager (提示框) .............................................................................................. 12

5.1          实例......................................................................................................... 12

5.2          方法......................................................................................................... 15

5.3          扩展......................................................................................................... 16

6.... NumberBox (数字框) .......................................................................................... 16

6.1          实例......................................................................................................... 16

6.2          参数......................................................................................................... 17

7.... ValidateBox (验证框) .......................................................................................... 18

7.1          实例......................................................................................................... 18

7.2          参数......................................................................................................... 20

7.3          方法......................................................................................................... 20

7.4          扩展......................................................................................................... 20

8.... Pagination (分页) ............................................................................................... 20

8.1          实例......................................................................................................... 20

8.2          参数......................................................................................................... 22

8.3          事件......................................................................................................... 23

9.... Window (窗口) ................................................................................................... 23

9.1          实例......................................................................................................... 23

9.2          参数......................................................................................................... 25

9.3          事件......................................................................................................... 26

9.4          方法......................................................................................................... 26

10... Panel (面板) ....................................................................................................... 26

10.1        实例......................................................................................................... 26

10.2        参数......................................................................................................... 28

10.3        事件......................................................................................................... 29

10.4        方法......................................................................................................... 29

11... Tabs (标签) ......................................................................................................... 30

11.1        实例......................................................................................................... 30

11.2        参数......................................................................................................... 32

11.3        事件......................................................................................................... 32

11.4        方法......................................................................................................... 33

11.5        标签面板属性.......................................................................................... 33

12... Tree (树) ............................................................................................................. 33

12.1        实例......................................................................................................... 33

12.2        参数......................................................................................................... 36

12.3        事件......................................................................................................... 37

12.4        方法......................................................................................................... 37

13... Layout (布局) ..................................................................................................... 38

13.1        实例......................................................................................................... 38

13.2        参数......................................................................................................... 39

13.3        方法......................................................................................................... 39

14... Datagrid (数据表) ............................................................................................... 39

14.1        实例......................................................................................................... 39

14.2        参数......................................................................................................... 43

14.3        Column 参数............................................................................................. 44

14.4        事件......................................................................................................... 45

14.5        方法......................................................................................................... 46

 

 

 

  1. ****Accordion (可折叠标签)

    1. ****实例

      1. 代码

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"  href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script type= "text/javascript" >

    $( function() {

        $('#aa').accordion( {

            width : 400,

            height : 200,

            fit : false

        });

    });

</script>

</head>

<body>

 

<div id= "aa" border="true" >

<div title= "Title1" icon= "icon-save" style= "overflow: auto; padding: 10px;" >

<h3 style= "color: #0099FF;" >Accordion for jQuery</h3>

<p>Accordion is a part of easyui framework for jQuery. It lets you define your accordion component on web page more easily.</p>

</div>

<div title= "Title2" icon= "icon-reload" selected= "true"

    style= "padding: 10px;" >content2</div>

<div title= "Title3" >content3</div>

</div>

 

</body>

</html>

 

      1. 效果图

 

 

1.1.3  扩展

实例html代码中

<div id= "aa" border="true" >

此行也可写成

<div id="aa" class="easyui-accordion" style="width:300px;height:200px;" fit="false" border="false">

,并且将js代码全部去掉,效果图是一样的。

    1. ****参数

      1. 容器参数
参数名称参数类型描述默认值
width数字可折叠标签的宽度。auto
height数字可折叠标签的高度。auto
fit布尔是否使可折叠标签自动缩放以适应父容器的大小,当为true时width和height参数将失效。false
border布尔是否显示边界线。true
      1. 面板参数

可折叠标签面板继承自面板(panel),许多属性定义在<div />标签里,下面的属性就是如此:

参数名称参数类型描述默认值
selected布尔设置可折叠标签中默认展开的标签页false

 

  1. ****DateBox (日期框)

    1. ****实例

      1. 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/lo…">

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

    function disable() {

       $ ('#dd').datebox('disable');

    }

    function enable() {

       $ ('#dd').datebox('enable');

    }

 

    /* 

     将Date/String类型,解析为String类型. 

     传入String类型,则先解析为Date类型 

     不正确的Date,返回 '' 

     如果时间部分为0,则忽略,只返回日期部分. 

     */

    function formatDate(v) {

       if (v instanceof Date) {

           var y = v.getFullYear();

           var m = v.getMonth() + 1;

           var d = v.getDate();

           var h = v.getHours();

           var i = v.getMinutes();

           var s = v.getSeconds();

           var ms = v.getMilliseconds();

           if (ms > 0)

              return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s

                     + '.' + ms;

           if (h > 0 || i > 0 || s > 0)

              return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;

           return y + '-' + m + '-' + d;

       }

       return '';

    }

 

    $ ( function() {

       $ ('#dd').datebox( {

           currentText : '今天',

           closeText : '关闭',

           disabled : false,

           required : true,

           missingMessage : '必填',

           formatter : formatDate

 

       });

    });

</script>

</head>

<body>

<h1>DateBox</h1>

<div style= "margin-bottom: 10px;" ><a href= "#" onclick=

    disable();

>disable</a>

<a href= "#" onclick=

    enable();

>enable</a></div>

<input id= "dd" ></input>

</body>

</html>

      1. 效果图

 

    1. ****参数
属性名类型描述默认值
currentText字符串为当前日期按钮显示的文本Today
closeText字符串关闭按钮显示的文本Close
disabled布尔如果为true则禁用输入框false
required布尔定义输入框是否为必添false
missingMessage字符串当输入框为空时提示的文本必填
formatterfunction格式化日期的函数,这个函数以’date’为参数,并且返回一个字符串——
parserfunction分析字符串的函数,这个函数以’date’为参数并返回一个日期——
    
    
    
    1. 事件
事件名参数描述 
onSelectdate当选择一个日期时触发 
    1. ****方法
方法名参数描述 
destroynone销毁组件 
disablenone禁用输入框. 
enablenone启用输入框 

 

  1. ****ComboBox( 组合框 )

    1. ****实例

      1. 代码

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       function loadData(){

           $ ('#cc').combobox({

              url:'combobox_data.json',//该文件内容在下面

              valueField:'id',

              textField:'text'

           });

       }

       function setValue(){

           $ ('#cc').combobox('setValue','2');

       }

       function getValue(){

           var val = $ ('#cc').combobox('getValue');

           alert(val);

       }

       function disable(){

           $ ('#cc').combobox('disable');

       }

       function enable(){

           $ ('#cc').combobox('enable');

       }

$ ( function() {

       $ ('#cc').combobox( {

           width:150,

listWidth:150,

listHeight:100,

//valuefield:'value',

//textField:'text',

//url:'combobox_data.json',

editable:false

       });

    });

    </script>

</head>

<body>

<h1>ComboBox</h1>

<div style= "margin-bottom: 10px;" ><a href= "#" onclick="loadData()">loadData</a>

<a href= "#" onclick="setValue()">setValue</a> <a href= "#"

    onclick="getValue()">getValue</a> <a href= "#" onclick="disable()">disable</a>

<a href= "#" onclick="enable()">enable</a></div>

 

<span>Options: </span>

<select id= "cc" name= "dept" required= "true" >

    <option value= "" >==请选择==</option>

    <option value= "0" >苹果</option>

    <option value= "1" >香蕉</option>

    <option value= "2" >鸭梨</option>

    <option value= "3" >西瓜</option>

    <option value= "4" >芒果</option>

</select>

</body>

</html>

 

combobox_data.json内容:

[{

       "id":1,

       "text":"text1"

},{

       "id":2,

       "text":"text2"

},{

       "id":3,

       "text":"text3",

       "selected":true

},{

       "id":4,

       "text":"text4"

},{

       "id":5,

       "text":"text5"

}]

      1. 效果图

 

    1. ****参数
属性名类型描述默认值
width数字组件的宽度auto
listWidth数字下拉列表的宽度null
listHeight数字下拉列表的高度null
valueField字符串基础数据值名称绑定到这个组合框value
textField字符串基础数据的字段的名称绑定到这个组合框text
editable布尔定义是否可以直接到文本域中键入文本true
url字符串加载列表数据的远程URLnull
mode字符串remote 加载远程数据 local 本地 远程接收的url 是q 接收的时候必须进行URL解码local
    1. ****事件
事件名参数描述
onLoadSuccessnone当远程数据成功加载时触发
onLoadErrornone当远程数据加载失败时触发
onSelectrecord当用户选择了一个列表项时触发
onChangenewValue, oldValue当文本域字段的值改变时触发
    1. ****方法
方法名参数描述
selectvalue选择下拉列表中的一项
setValueparam设定指定值到文本域,参数可以是一个字符串,也可以是一个Javascript对象,如果是对象,必须包含两个属性各对应valueField和TextField属性。
getValuenone获取字段值
reloadurl请求远程列表数据.

 

  1. ****Dialog (对话框)

    1. ****实例

      1. 代码

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       $ (function(){

           $ ('#dd').dialog({

              title:'对话框',

              collapsible:true,

              minimizable:true,

              maximizable:true,

              resizable:true,            

 

              toolbar:[{

                  text:'Add',

                  iconCls:'icon-add',

                  handler:function(){

                     alert('add');

                  }

              },'-',{

                  text:'Save',

                  iconCls:'icon-save',

                  handler:function(){

                     alert('save');

                  }

              }],

              buttons:[{

                  text:'Ok',

                  iconCls:'icon-ok',

                  handler:function(){

                     alert('ok');

                  }

              },{

                  text:'Cancel',

                  handler:function(){

                     $ ('#dd').dialog('close');

                  }

              }]

           });

       });

       function open1(){

           $ ('#dd').dialog('open');

       }

       function close1(){

           $ ('#dd').dialog('close');

       }

    </script>

</head>

<body>

<h1>Dialog</h1>

<div style= "margin-bottom: 10px;" ><a href= "#" onclick="open1()">open1</a>

<a href= "#" onclick="close1()">close1</a></div>

<div id= "dd" icon= "icon-save"

    style= "padding: 5px; width: 400px; height: 200px;" >

<p>dialog content.</p>

<p>dialog content.</p>

<p>dialog content.</p>

<p>dialog content.</p>

<p>dialog content.</p>

<p>dialog content.</p>

<p>dialog content.</p>

<p>dialog content.</p>

</div>

</body>

</html>

      1. 效果图

 

    1. ****参数
属性名类型描述默认值
title字符串对话框的标题文本New Dialog
collapsible布尔定义是否显示可折叠按钮false
minimizable布尔定义是否显示最小化按钮false
maximizable布尔定义是否显示最大化按钮false
resizable布尔定义对话框是否可编辑大小false
toolbar数组对话框上的工具条,每个工具条包括:text,iconCls,disabled,handleretc.null
buttons数组对话框底部的按钮,每个按钮包括:text,iconCls,handleretc.null
    1. ****事件

Dialog的事件和窗口(Window)的事件相同。

    1. ****方法

Dialog的函数方法和窗口(Window)的相同。

 

  1. ****Messager (提示框)

    1. ****实例

      1. 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/lo…">

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       function show1(){

           $.messager.show({

              title:'My Title',

              msg:'Message will be closed after 4 seconds.',

              showType:'show'

           });

       }

       function show2(){

           $.messager.show({

              title:'My Title',

              msg:'Message will be closed after 5 seconds.',

              timeout:5000,

              showType:'slide'

           });

       }

       function show3(){

           $.messager.show({

              title:'My Title',

              msg:'Message never be closed.',

              timeout:0,

              showType:'fade'

           });

       }

       function alert1(){

           $.messager.alert('My Title','Here is a message!');

       }

       function alert2(){

           $.messager.alert('My Title','Here is a error message!','error');

       }

       function alert3(){

           $.messager.alert('My Title','Here is a info message!','info');

       }

       function alert4(){

           $.messager.alert('My Title','Here is a question message!','question');

       }

       function alert5(){

           $.messager.alert('My Title','Here is a warning message!','warning');

       }

       function confirm1(){

           $.messager.confirm('My Title', 'Are you confirm this?', function(r){

              if (r){

                  alert('confirmed:'+r);

                  location.href = 'www.google.com';

              }

           });

       }

       function prompt1(){

           $.messager.prompt('My Title', 'Please type something', function(r){

              if (r){

                  alert('you type:'+r);

              }

           });

       }

$ (function(){

$.messager.defaults={ok: " 确定 " ,cancel: " 取消 " };

});

    </script>

</head>

<body>

<h1>Messager</h1>

<div><a href= "javascript:void(0)" onclick="show1()">show</a> | <a

    href= "#" onclick="show2()">slide</a> | <a href= "#" onclick="show3()">fade</a>

|</div>

 

<div><a href= "#" onclick="alert1()">alert</a> | <a href= "#"

    onclick="alert2()">alert(error)</a> | <a href= "#" onclick="alert3()">alert(info)</a>

| <a href= "#" onclick="alert4()">alert(question)</a> | <a href= "#"

    onclick="alert5()">alert(warning)</a></div>

<div><a href= "#" onclick="confirm1();">confirm</a></div>

<div><a href= "#" onclick="prompt1()">prompt</a></div>

<div style= "height: 600px;" ></div>

</body>

</html>

      1. 效果图

 

 

 

 

    1. ****方法

 

方法名参数描述
$.messager.showoptions在屏幕的右下角显示一个消息窗口。这些选项的参数可以是一下的一个配置对象: showType:定义如何将显示消息窗口。可用的值是:null,slide,fade,show。默认值是slide。 showSpeed:定义消息窗口完成的时间(以毫秒为单位), 默认值600。 width:定义消息窗口的宽度。 默认值250。 height:定义消息窗口的高度。 默认值100。 msg:定义显示的消息文本。 title:定义显示在标题面板显示的标题文本。 timeout:如果定义为0,消息窗口将不会关闭,除非用户关闭它。如果定义为非0值,当超时后消息窗口将自动关闭。
$.messager.alerttitle, msg, icon, fn显示一个警告窗口。参数如下: title:显示在标题面板的标题文本。 msg:提示框显示的消息文本。 icon:提示框显示的图标。可用的值是:error,question,info,warning. fn:当窗口关闭时触发的回调函数。
$.messager.confirmtitle, msg, fn显示一个含有确定和取消按钮的确认消息窗口。参数如下: title:显示在标题面板的标题文本。 msg:确认消息窗口显示的消息文本。 fn(b):当用户点击按钮后触发的回调函数,如果点击OK则给回调函数传true,如果点击cancel则传false。
$.messager.prompttitle, msg, fn显示一个确定和取消按钮的信息提示窗口,提示用户输入一些文本。参数如下: title:显示在标题面板的标题文本。 msg:提示窗口显示的消息文本。 fn(val):用户点击按钮后的回调函,参数是用户输入的内容。
   

 

    1. ****扩展

可以通过$.messager.defaults方法自定义alert框的ok按钮和cancel按钮上显示的文字。

名字类型描述默认值  
ok字符串Ok按钮上的文本Ok 
cancel字符串Cancel按钮上的文本Cancel 

 

  1. ****NumberBox (数字框)

    1. ****实例

      1. 代码

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       function disable(){

           $ ('#nn').numberbox('disable');

       }

       function enable(){

           $ ('#nn').numberbox('enable');

       }

$ (function(){

$ ('#nn').numberbox({min:5.5,max:20,precision:2});

});

    </script>

</head>

<body>

<h1>NumberBox</h1>

<p>The Box can only input number.</p>

<div style= "margin-bottom: 10px;" ><a href= "#" onclick="disable()">disable</a>

<a href= "#" onclick="enable()">enable</a></div>

<input id= "nn" required= "true" />

</body>

</html>

      1. 效果图

 

    1. ****参数
选项名类型描述默认值 
min数字文本框中可允许的最小值null 
max数字文本框中可允许的最大值null 
precision数字最高可精确到小数点后几位0 

 

  1. ****ValidateBox (验证框)

    1. ****实例

      1. 代码

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<style type= "text/css" >

input,textarea {

    width: 200px;

    border: 1px solid #ccc;

    padding: 2px;

}

</style>

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

function valid(){

alert( $ ('#dfe').validatebox('isValid'));

}

$ (function(){

$ .extend($.fn.validatebox.defaults.rules, {

    minLength: {

        validator: function(value, param){

            return value.length >= param[0];

        },

        message: 'Please enter at least {0} characters.'

    }

});

 

});

    </script>

</head>

<body>

<h1>ValidateBox <a href= "#0" onclick="valid();">EmailisValid</a></h1>

<div>

<table>

    <tr>

       <td>Name:</td>

       <td><input class= "easyui-validatebox" required= "true"

           validType= "length[1,3]" ></td>

    </tr>

    <tr>

       <td>Email:</td>

       <td><input id= "dfe" class= "easyui-validatebox"

           invalidMessage= "email 格式错误 " validType= "email" ></td>

    </tr>

    <tr>

       <td>URL:</td>

       <td><input class= "easyui-validatebox" required= "true"

           validType= "url" ></td>

    </tr>

    <tr>

       <td>testr:</td>

       <td><input class= "easyui-validatebox" validType= "minLength[5]"

           invalidMessage= " 至少 5 个字符 " ></td>

    </tr>

    <tr>

       <td>Note:</td>

       <td><textarea class= "easyui-validatebox" required= "true"

           missingMessage= " 必填 " style= "height: 100px;" ></textarea></td>

    </tr>

</table>

</div>

</body>

</html>

      1. 效果图

 

    1. ****参数
属性名类型描述默认值
required布尔定义文本域是否为必填项false
validType字符串定义字段的验证类型url(匹配电子邮件正则表达式规则), email(匹配URL正则表达式规则),length[0,100](允许字符串长度的范围)etc.null
missingMessage字符串当文本框为空时提示的文本信息This field is required.
invalidMessage字符串当文本框内容不合法时提示的文本信息null
    1. ****方法
方法名参数描述
destroynone删除并且销毁组件
validatenone做验证以确定文本框的内容是否是有效的。
isValidnone调用验证方法并返回验证结果,true或者false
    1. ****扩展

当然也可以自定义验证规则,重写$.fn.validatebox.defaults.rules 可以定义一个校验器的功能和无效的显示消息。例如,要定义一个minLength有效的类型:

$.extend($.fn.validatebox.defaults.rules, {

minLength: {

validator: function(value, param){

return value.length >= param[0];

},

message: 'Please enter at least {0} characters.'

}

});定义好以后我们就可以使用了,下面的代码表示输入的最小长度是5个字符:

<input class="easyui-validatebox" validType="minLength[5]">

 

  1. ****Pagination (分页)

    1. ****实例

      1. 代码

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       $ (function(){

           $ ('#pp').pagination({

              total:114,

pageSize:15,

pageNumber:2,

pageList:[10,15,20,30,50,100],

loading:false,

showPageList:true,

showRefresh:true,

beforePageText:'第',

afterPageText:'页,共{pages}页',

displayMsg:'{from}-{to}/{total}',

              buttons:[{

                  iconCls:'icon-add',

                  handler:function(){

                     alert('add');

                  }

              },{

                  iconCls:'icon-cut',

                  handler:function(){

                     alert('cut');

                  }

              },{

                  iconCls:'icon-save',

                  handler:function(){

                     alert('save');

                  }

              }],

              onSelectPage:function(pageNumber, pageSize){

                  $ (this).pagination('loading');

                  alert('pageNumber:'+pageNumber+',pageSize:'+pageSize);

                  $ (this).pagination('loaded');

              }

           });

       });

    </script>

</head>

<body>

<h1>Pagination</h1>

<div style= "margin: 10px 0;" ><a href= "#"

    onclick="javascript: $ ('#pp').pagination({loading:false})">loaded</a> <a

    href= "#" onclick="javascript: $ ('#pp').pagination({loading:true})">loading</a>

</div>

 

<div id= "pp"

    style= "width: 500px; background: #efefef; border: 1px solid #ccc;" ></div>

</body>

</html>

      1. 效果图

 

    1. ****参数
属性名类型描述默认值
total数字当分页建立时设置记录的总数量1
pageSize数字每一页显示的数量10
pageNumber数字当分页建立时,显示的页数1
pageList数组用户可以修改每一页的大小,pageList属性定义了多少种大小可以改变.[10,20,30,50]
loading布尔定义数据是否正在加载false
buttons数组定义自定义按钮,每个按钮包含两个属性:iconCls:   显示背景图像的CSS类handler:   当一个按钮被点击时的处理函数null
showPageList布尔定义是否显示页面列表true
showRefresh布尔定义是否显示刷新按钮true
beforePageText字符串在输入框组件前显示的标签Page
afterPageText字符串在输入框组件后显示的标签Of  {pages}
displayMsg字符串显示一个页面的信息。Displaying {from} {to} of       {total}    items
    1. ****事件
事件名参数描述
onSelectPagepageNumber, pageSize当用户选择一个新页时触发,回调函数包含两个参数:pageNumber: 新页面的页数pageSize: 新页面的大小
onBeforeRefreshageNumber, pageSize刷新按钮被点击之前触发,如果返回false则取消刷新操作
onRefreshageNumber, pageSize刷新以后触发
onChangePageSizeageSize改变页面大小时触发

 

  1. ****Window (窗口)

窗口的主要用法和面板(panel)用法差不多

    1. ****实例

      1. 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

 

"www.w3.org/TR/html4/lo…">

<html style= "height:100%;width:100%;" >

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" >

<title>Insert title here</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       function resize(){

           $ ('#w').window({

              title: 'yewen2',

              width: 600,

              collapsible:false,

minimizable:false,

maximizable:false,

closable:false,

              closed: false,

              height: 300,

draggable:false,

resizable:false,

shadow:false,

modal:true

           });

       }

       function open1(){

           $ ('#w').window('open');

       }

       function close1(){

           $ ('#w').window('close');

       }

       function test(){

           $ ('#test').window('open');

       }

    </script>

</head>

<body style= "height: 100%; width: 100%; overflow: hidden; border: none;" >

<h1>Window</h1>

<div><a href= "javascript:void(0)" onclick="resize()">resize</a> <a

    href= "javascript:void(0)" onclick="open1()">open</a> <a

    href= "javascript:void(0)" onclick="close1()">close</a></div>

<div id= "w" class= "easyui-window" title= "My Window" icon= "icon-save"

    style= "width: 500px; height: 200px; padding: 5px; background: #fafafa;" >

<div class= "easyui-layout" fit= "true" >

<div region= "center" border= "false"

    style= "padding: 10px; background: #fff; border: 1px solid #ccc;" >

jQuery EasyUI framework help you build your web page easily. <br />

<br />

click <a href= "#" onclick="test()">here</a> to popup another window.</div>

<div region= "south" border= "false"

    style= "text- align: right; height: 30px; line-height: 30px;" ><a

    class= "easyui-linkbutton" icon= "icon-ok" href= "javascript:void(0)"

    onclick="resize()">Ok</a> <a class= "easyui-linkbutton"

    icon= "icon-cancel" href= "javascript:void(0)" onclick="resize()">Cancel</a>

</div>

</div>

</div>

<div id= "test" class= "easyui-window" closed= "true" modal= "true"

    title= "Test Window" style= "width: 300px; height: 100px;" ></div>

</body>

</html>

      1. 效果图

 

 

    1. ****参数

大多数的属性和面板(panel)的属性是相同的,下面列出一些Window私有的属性:

属性名类型描述默认值
zIndex数字窗口的z-index属性,可以通过这个属性来增加9000
draggable布尔定义窗口是否可被拖动true
resizable布尔定义窗口是否可以被改变大小true
shadow布尔如果设置为true,窗口的阴影也将显示。true
modal布尔定义窗口是否是一个模式窗口。false

Window也重写了Panel里的一些属性

属性名类型描述默认值
title字符串窗口的标题文本New Window
collapsible布尔定义是否显示可折叠定义按钮true
minimizable布尔定义是否显示最小化按钮true
maximizable布尔定义是否显示最大化按钮true
closable布尔定义是否显示关闭按钮true

 

    1. ****事件

Window的事件和面板(panel)的事件相同

    1. ****方法

除了”header”和”body”以外,Window的函数方法和面板(panel)的相同

 

  1. ****Panel (面板)

    1. ****实例

      1. 代码

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       function open1(){

           $ ('#p').panel('open');

       }

       function close1(){

           $ ('#p').panel('close');

       }

       function load1(){

           $ ('#p').panel({

              href:'tabs_href_test.html'

           });

$ ('#p').panel('open');

       }

    </script>

</head>

<body style= "background: #fafafa;" >

<h1>Panel</h1>

<div style= "margin-bottom: 10px;" ><a href= "#" onclick="open1()">open</a>

<a href= "#" onclick="close1()">close</a> <a href= "#" onclick="load1()">load</a>

</div>

<div

    style= "width: 600px; height: 300px; border: 1px solid red; padding: 5px;" >

<div id= "p" class= "easyui-panel" title= "My Title" icon= "icon-save"

    collapsible= "true" minimizable= "true" maximizable=true closable= "true"

    style= "width: 500px; height: 150px; padding: 10px; background: #fafafa;" >

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

<p>panel</p>

</div>

</div>

 

</body>

</html>

      1. 效果图

 

    1. ****参数
名字类型描述默认值
title字符串在面板头部显示的标题文本null
iconCls字符串一个CSS类来显示在面板中的16x16图标null
width数字设置面板的宽度auto
height数字设置面板的高度auto
left数字设置面板左侧位置null
top数字设置面板的顶部位置null
cls字符串给面板添加一个CSS类null
headerCls字符串给面板头部添加一个CSS类null
bodyCls字符串给面板主体添加一个CSS类null
style对象给面板自定义样式{}
fit布尔当设置为true,面板尺寸将适合它的父容器。false
border布尔定义面板的边框true
doSize布尔当设置为true,面板载创建的时候将被调整和重新布局true
collapsible布尔定义是否显示可折叠定义按钮false
minimizable布尔定义是否显示最小化按钮false
maximizable布尔定义是否显示最大化按钮false
closable布尔定义是否显示关闭按钮false
tools数组自定义工具,每个工具可以包含两个属性:iconCls and handler[]
collapsed布尔定义在初始化的时候折叠面板false
minimized布尔定义在初始化的时候最小化面板false
maximized布尔定义在初始化的时候最大化面板false
closed布尔定义在初始化的时候关闭面板false
href字符串一个远程的URL加载数据,然后显示在面板中null
loadingMessage字符串当加载远程数据时,在面板中显示的信息Loading…
    1. ****事件
名字参数描述
onLoadnone当远程数据加载时触发
onBeforeOpennone当面板打开之前触发
onOpennone当面板打开之后触发
onBeforeClosenone当面板关闭之前触发
onClosenone当面板关闭之后触发
onBeforeDestroynone当面板销毁之前触发
onDestroynone当面板关闭之后触发
onBeforeCollpasenone当面板折叠之前触发
onCollapsenone当面板折叠之后触发
onBeforeExpandnone当面板展开之前触发
onExpandnone当面板展开之后触发
onResizewidth, height当面板调整大小之后触发width: 新的宽度;height: 新的高度
onMoveleft,top当面板移动之后触发left: 新的左侧位置top: 新的顶部位置
onMaximizenone当窗口最大化的时候被触发
onRestorenone当窗口恢复到原来的大小时被触发
onMinimizenone当窗口最小化的时候被触发
    1. ****方法
名字参数描述
optionsnone返回设置的属性值
panelnone返回面板对象
headernone返回面板头部对象
bodynone返回面板主体对象
setTitletitle设置面板头部标题
openforceOpen当forceOpen设置为true,面板被打开的时候忽略onBeforeOpen回调函数
closeforceClose当forceClose设置为true,面板被关闭的时候忽略onBeforeClose回调函数
destroyforceDestroy当forceDestroy设置为true,面板被销毁的时候忽略onBeforeDestroy回调函数
refreshnone当设置了href值时,刷新面板来加载远程数据
resizeoptions设置面板的大小和布局,这些选项包含以下的属性:width: 新面板的宽度; height: 新面板的高度; left: 新面板的左侧位置; top: 新面板的顶部位置
moveoptions移动面板到一个新的位置,这些选项包含以下属性: left: 新面板的左侧位置;top: 新面板的顶部位置

 

  1. ****Tabs (标签)

    1. ****实例

      1. 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/lo…">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>jQuery EasyUI</title>

       <link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">

       <link rel="stylesheet" type="text/css" href="../themes/icon.css">

       <script type="text/javascript" src="../jquery-1.4.2.min.js"></script>

       <script type="text/javascript" src="../jquery.easyui.min.js"></script>

       <script>

              var index = 0;

              function addTab(){

                     index++;

                     $('#tt').tabs('add',{

                            title:'New Tab ' + index,

                            content:'Tab Body ' + index,

                            closable:true

                     });

              }

       </script>

</head>

<body>

       <h1>Tabs</h1>

       <div>

              <a class="easyui-linkbutton" icon="icon-add" href="javascript:void(0)" οnclick="addTab()">add tab</a>

       </div>

       <br/>

       <div id="tt" class="easyui-tabs" style="width:500px;height:250px;">

              <div title="Tab1" style="padding:20px;display:none;">

              </div>

              <div title="Tab2" closable="true" style="overflow:auto;padding:20px;display:none;" cache="false" href="tabs_href_test.html"> This is Tab2 width close

 

button.</div>

              <div title="Tab3" icon="icon-reload" closable="true" style="padding:20px;display:none;">

              <table id="test" class="easyui-datagrid" fit="true">

                     <thead>

                            <tr>

                                   <th field="f1" width="60">field1</th>

                                   <th field="f2" width="60">field2</th>

                                   <th field="f3" width="60">field3</th>

                            </tr>

                     </thead>

                     <tbody>

                            <tr>

                                   <td>d1</td>

                                   <td>d2</td>

                                   <td>d3</td>

                            </tr>

                            <tr>

                                   <td>d11</td>

                                   <td>d21</td>

                                   <td>d31</td>

                            </tr>

                     </tbody>

              </table>

              </div>

              <div title="Tab4 with iframe" closable="true" style="width:100%;height:100%;display:none;">

                     <iframe scrolling="yes" frameborder="0"  src="www.google.com" style="width:100%;height:100%;"></iframe>

              </div>

              <div title="Tab5 with sub tabs" closable="true" icon="icon-cut" 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>

      1. 效果图

 

    1. ****参数
参数名参数描述默认值
width数字标签容器的宽度auto
height数字标签容器的高度auto
idSeed数字The base id seed to generate tab panel’s DOM id attribute.0
plain布尔如果为ture标签没有背景图片false
fit布尔如果为ture则设置标签的大小以适应它的容器的父容器false
border布尔如果为true则显示标签容器的边框true
scrollIncrement数字滚动按钮每次被按下时滚动的像素值100
scrollDuration数字每次滚动持续的毫秒数400
    1. ****事件
事件名参数描述
onLoadarguments当一个AJAX标签加载远程数据完成时被触发,参数和jQuery.ajax成功返回的回调函数相同
onSelecttitle当用户选择一个标签面板时被触发
onClosetitle当用户关闭一个标签面板时被触发
    1. ****方法
方法名参数描述
resizenone调整标签容器的大小和布局
addoptions添加新标签面板,可选参数是一个配置对象,详细信息可以查看下面的标签面板属性
closetitle关闭一个标签面板,标题参数表明被关闭的面板
selecttitle选择一个标签面板
existstitle指示特定的标签是否存在
    1. ****标签面板属性
属性名类型描述默认值
id字符串标签面板的ID属性null
title字符串标签面板的文本标题 
content字符串标签面板的主体内容 
href字符串填充标签内容的远程URL地址null
cache布尔如果为true,当设置href时,对标签面板进行缓存true
icon字符串标签面板上标题的图标CSS类null
closable布尔如果为true,标签面板会显示出关闭按钮,点击可以关闭选项卡面板。false
selected布尔如果为true,标签标签面板将被选中false
width数字标签面板的宽度auto
height数字标签面板的高度auto

 

  1. ****Tree (树)

    1. ****实例

      1. 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/lo…">

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script type= "text/javascript" >

       $ (function(){

           $ ('#tt1').tree({

              animate:true,

              onClick:function(node){

                  alert('you click '+node.text);

              }

           });

           $ ('#tt2').tree({

              checkbox: true,

              url: 'tree_data.json',

              onClick:function(node){

                  alert('you click '+node.text);

              }

           });

       });

       function reload(){

           $ ('#tt2').tree('reload');

       }

       function getChecked(){

           var nodes = $ ('#tt2').tree('getChecked');

           var s = '';

           for(var i=0; i<nodes.length; i++){

              if (s != '') s += ',';

              s += nodes[i].text;

           }

           alert(s);

       }

       function getSelected(){

           var node = $ ('#tt2').tree('getSelected');

           alert(node.text);

       }

       function collapse(){

           var node = $ ('#tt2').tree('getSelected');

           $ ('#tt2').tree('collapse',node.target);

       }

       function expand(){

           var node = $ ('#tt2').tree('getSelected');

           $ ('#tt2').tree('expand',node.target);

       }

       function append(){

           var node = $ ('#tt2').tree('getSelected');

           $ ('#tt2').tree('append',{

              parent: node.target,

              data:[{

                  text:'new1'

              },{

                  text:'new2',

                  state:'closed',

                  children:[{

                     text:'subnew1'

                  },{

                     text:'subnew2'

                  }]

              }]

           });

       }

       function remove(){

           var node = $ ('#tt2').tree('getSelected');

           $ ('#tt2').tree('remove', node.target);

       }

       function isLeaf(){

           var node = $ ('#tt2').tree('getSelected');

           var b = $ ('#tt2').tree('isLeaf', node.target);

           alert(b )

       }

    </script>

</head>

<body>

<h1>Tree</h1>

<p>Create from HTML markup</p>

<ul id= "tt1" class= "easyui-tree" >

    <li><span>Folder</span>

    <ul>

       <li><span>Sub Folder 1</span>

       <ul>

           <li><span><a href= "#" >File 11</a></span></li>

           <li><span>File 12</span></li>

           <li><span>File 13</span></li>

       </ul>

       </li>

       <li><span>File 2</span></li>

        <li><span>File 3</span></li>

    </ul>

    </li>

    <li><span>File21</span></li>

</ul>

<hr></hr>

<p>Create from JSON data</p>

<div style= "margin: 10px;" ><a href= "#" onclick="reload()">reload</a>

<a href= "#" onclick="getChecked()">getChecked</a> <a href= "#"

    onclick="getSelected()">getSelected</a> <a href= "#"

    onclick="collapse()">collapse</a> <a href= "#" onclick="expand()">expand</a>

<a href= "#" onclick="append()">append</a> <a href= "#" onclick="remove()">remove</a>

<a href= "#" onclick="isLeaf()">isLeaf</a></div>

 

<ul id= "tt2" ></ul>

</body>

</html>

      1. 效果图

 

    1. ****参数
选项名类型描述默认值 
url字符串一个网址retrive远程数据。null 
animate布尔当节点展开或折叠是否显示动画效果。false 
checkbox布尔是否带复选框False 

 

    1. ****事件
事件名参数描述
onClicknode用户点击一个节点时触发。,该节点参数包含以下属性:id:节点IDtext:节点的文本attributes:节点自定义属性target:点击DOM对象的目标
onDblClicknode用户双击一个节点时触发,参数同onclick事件
onLoadSuccessarguments加载数据成功时触发,参数arguments类似jQuery.ajax.的success函数
onLoadErrorarguments加载数据成功时触发,参数arguments类似jQuery.ajax.的error函数

 

    1. ****方法
方法名参数描述
optionsnone返回树的所有参数对象
loadDatadata加载树的数据
reloadnone重新加载树的数据
getRootnone返回树的root节点
getRootsnone返回树的所有root节点
getParenttarget返回某个节点的父节点
getChildrentarget返回某个节点的孩子节点
getCheckednone获取被勾选的节点
getSelectednone获取选中的节点,并返回它,如果没有节点选择返回null。
isLeaftarget判断某个节点是否叶子节点
selecttarget选择一个节点,目标参数表明该节点的DOM对象。
collapsetarget折叠节点,目标参数表明该节点的DOM对象。
expandtarget展开一个节点,目标参数表明该节点的DOM对象。
collapseAllnone折叠所有节点
expandAllnone展开所有节点
appendparam一些子节点追加到父节点。参数有两个属性:parent: DOM对象,父节点追加。data:数组,节点数据。
toggletarget绑定某个节点的展开或者折叠状态,使之不能再改变。
removetarget删除一个节点和它的子节点,目标参数表明该节点的DOM对象。
updateparam更新指定的节点,参数param包含如下属性:Target:目标节点;id,text,iconCls,checked,etc.

 

  1. ****Layout (布局)

    1. ****实例

此例最外层写在了body上,也可以写在某个div上。

      1. 代码

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>jQuery EasyUI</title>

       <link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">

       <script type="text/javascript" src="../jquery-1.4.2.min.js"></script>

       <script type="text/javascript" src="../jquery.easyui.min.js"></script>

       <script>

              $(function(){

                     var p = $('body').layout('panel','west').panel({

                            onCollapse:function(){

                                   alert('collapse');

                            }

                     });

                     setTimeout(function(){

                            $('body').layout('collapse','east');

                     },0);

              });

       </script>

</head>

<body class="easyui-layout">

       <div region="north"  border="false" style="height:60px;background:#B3DFDA;">north region</div>

       <div region="west" split="true" title="West" style="width:150px;padding:10px;">west content</div>

       <div region="east" split="true" title="East" style="width:100px;padding:10px;">east region</div>

       <div region="south" border="false" style="height:50px;background:#A9FACD;padding:10px;">south region</div>

       <div region="center" title="Main Title">

       </div>

</body>

</html>

      1. 效果图

 

    1. ****参数

所有属性都必须定义在布局面板创建的<div/>标记上。

名称类型描述默认值
title字符串布局面板的标题文本null
region字符串定义布局面板的位置,该值是下列之一: north,       south,  east,       west, center. 
border布尔如果为ture则显示布局面板的边框true
split布尔如果为ture则显示分隔栏,用户可以用它来改变布局面板的大小false
icon字符串在面板头部显示图标的CSSnull
href字符串从远程地址加载数据的URLnull

 

    1. ****方法
方法名参数描述
panelregion返回某个方位的面板,参数region取值可以是:north,south,east,west,center
collapseregion收缩某个方位的面板,参数region取值可以是:north,south,east,west
expandregion展开某个方位的面板,参数region取值可以是:north,south,east,west
   

 

  1. ****Datagrid (数据表)

    1. ****实例

      1. 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/lo…">

<html>

<head>

<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" >

<title>jQuery EasyUI</title>

<link rel= "stylesheet" type= "text/css"

    href= "../themes/default/easyui.css" >

<link rel= "stylesheet" type= "text/css" href= "../themes/icon.css" >

<script type= "text/javascript" src= "../jquery-1.4.2.min.js" ></script>

<script type= "text/javascript" src= "../jquery.easyui.min.js" ></script>

<script>

       $ (function(){

           $ ('#test').datagrid({

               title:'My Title',

              iconCls:'icon-save',

              width:800,

              height:450,

              nowrap: true,

              striped: true,

              url:'datagrid_data.json',

              sortName: 'code',

              sortOrder: 'desc',

              idField:'code',

              frozenColumns:[[

                    {field:'ck',checkbox:true},

                    {title:'code',field:'code',width:80,sortable:true}

              ]],

              columns:[[

                   {title:'Base Information',colspan:3},

                  {field:'opt',title:'Operation',width:100,align:'center', rowspan:2,

                     formatter:function(value,rec){

                         return '<span style="color:red">Edit Delete</span>';

                     }

                  }

              ],[

                  {field:'name',title:'Name',width:120},

                  {field:'addr',title:'Address',width:120,rowspan:2,sortable:true},

                  {field:'col4',title:'Col41',width:150,rowspan:2}

              ]],

              pagination:true,

              rownumbers:true,

              singleSelect:true,

              toolbar:[{

                  text:'Add',

                  iconCls:'icon-add',

                  handler:function(){

                     alert('add' )

                  }

              },{

                  text:'Cut',

                  iconCls:'icon-cut',

                  disabled:true,

                  handler:function(){

                     alert('cut' )

                  }

              },'-',{

                  text:'Save',

                  iconCls:'icon-save',

                  handler:function(){

                     alert('save' )

                  }

              }]

           });

           var p = $ ('#test').datagrid('getPager');

           if (p){

              $ (p).pagination({

                  onBeforeRefresh:function(){

                     alert('before refresh');

                  }

              });

           }

       });

       function resize(){

           $ ('#test').datagrid({

              title: 'New Title',

              striped: true,

              width: 650,

              queryParams:{

                  p:'param test',

                  name:'My Name'

              }

           });

       }

       function getSelected(){

           var selected = $ ('#test').datagrid('getSelected');

           alert(selected.code+":"+selected.name);

       }

       function getSelections(){

           var ids = [];

           var rows = $ ('#test').datagrid('getSelections');

           for(var i=0;i<rows.length;i++){

              ids.push(rows[i].code);

           }

           alert(ids.join(':') )

       }

       function clearSelections(){

           $ ('#test').datagrid('clearSelections');

       }

       function selectRow(){

           $ ('#test').datagrid('selectRow',2);

       }

       function selectRecord(){

           $ ('#test').datagrid('selectRecord','002');

       }

       function unselectRow(){

           $ ('#test').datagrid('unselectRow',2);

       }

    </script>

</head>

<body>

<h1>DataGrid</h1>

<div style= "margin-bottom: 10px;" ><a href= "#" onclick="resize()">resize</a>

<a href= "#" onclick="getSelected()">getSelected</a> <a href= "#"

    onclick="getSelections()">getSelections</a> <a href= "#"

    onclick="clearSelections()">clearSelections</a> <a href= "#"

    onclick="selectRow()">selectRow</a> <a href= "#"

    onclick="selectRecord()">selectRecord</a> <a href= "#"

    onclick="unselectRow()">unselectRow</a></div>

 

<table id= "test" ></table>

 

</body>

</html>

      1. 效果图

 

    1. ****参数
NameTypeDescriptionDefault
title字符串标题文字null
iconCls字符串一个css类,将提供一个背景图片作为标题图标null
border布尔是否显示面板的边界。true
width数字表格的宽度auto
height数字表格的高度auto
columns数组表格的列的配置对象,详见下面column属性介绍。null
frozenColumns数组与columns属性相通,但这些列将固定在左侧,不得变动。null
striped布尔是否显示斑马线false
method字符串远程数据的获取类型,可取值为post或getpost
nowrap布尔是否在一行显示数据true
idField字符串指定哪些字段时标识字段null
url字符串从远程请求数据的地址null
loadMsg字符串当远程加载数据时,现实的等待信息提示Processing, please wait …
pagination布尔是否显示底部分页工具栏false
rownumbers布尔是否显示行号列false
singleSelect布尔是否允许只选择一行false
fit布尔是否允许表格自动缩放,以适应父容器false
pageNumber数字初始化页码1
pageSize数字初始化页面大小10
pageList数组初始化页面大小选择清单[10,20,30,40,50]
queryParams对象当请求远程数据时,发送的额外的参数{}
sortName字符串定义哪一列可以排序null
sortOrder字符串定义列排序的方式,递增(asc)或递减(desc)asc
editors对象定义当编辑某行数据时的编辑器predefined editors

 

    1. ****Column参数
NameTypeDescriptionDefault
title字符串列标题文字undefined
field字符串列字段名称undefined
width数字列宽度undefined
rowspan数字该列占几行单元格undefined
colspan数字该列占几列单元格undefined
align字符串数据对其方式,可选值有left,right,centerundefined
sortable布尔是否允许该列排序undefined
checkbox布尔是否显示选择框undefined
formatter函数包含三个参数:value: the field value.rowData: the row record datarowIndex: the row index.undefined
editorstring,objectIndicate the edit type. When string indicates the edit type, when object contains two properties: type: string, the edit type, possible type is: text,textarea,checkbox,numberbox,validatebox,datebox,combobox,combotree. options: object, the editor options corresponding to the edit type.undefined

 

    1. ****事件
NameParametersDescription
onLoadSuccessdata远程数据加载成功时触发
onLoadErrornone远程数据加载失败时触发
onBeforeLoaddata请求发出去,加载数据前触发。如果返回false,加载数据动作则退出
onClickRowrowIndex, rowData当用户点击某行时触发, the parameters contains: rowIndex: the clicked row index, start with 0 rowData: the record corresponding to the clicked row
onDblClickRowrowIndex, rowData当用户双击某行时触发, the parameters contains: rowIndex: the clicked row index, start with 0 rowData: the record corresponding to the clicked row
onSortColumnsort, order当用户排序某列时触发, the parameters contains: sort: the sort column field name order: the sort column order
onSelectrowIndex, rowData当用户选择某行时触发, the parameters contains: rowIndex: the selected row index, start with 0 rowData: the record corresponding to the selected row
onUnselectrowIndex, rowData当用户取消选择某行时触发, the parameters contains: rowIndex: the unselected row index, start with 0 rowData: the record corresponding to the unselected row
onBeforeEditrowIndex, rowData当用户开始编辑某行时触发, the parameters contains: rowIndex: the editing row index, start with 0 rowData: the record corresponding to the editing row
onAfterEditrowIndex, rowData, changes当用户完成编辑某行时触发, the parameters contains: rowIndex: the editing row index, start with 0 rowData: the record corresponding to the editing row changes: the changed field/value pairs
onCancelEditrowIndex, rowData当用户退出编辑某行时触发, the parameters contains: rowIndex: the editing row index, start with 0 rowData: the record corresponding to the editing row

 

    1. ****方法
NameParameterDescription
optionsnone返回所有参数的对象
getPagernone返回分页对象
resizenone调整表格大小
reloadparam重新加载行
fixColumnSizenone固定列的大小
loadDataparam加载本地数据,旧行将被删除
getDatanone返回已加载的数据
getRowsnone返回当前页的行数
getSelectednone返回第一次选择的行记录
getSelectionsnone返回所有选定行,如果没选择记录,则返回空数组
clearSelectionsnone取消所有选择
selectAllnone选择当前页所有行
selectRowindex选择某行,行索引以0开始
selectRecordidValue通过id值选择一行
unselectRowindex取消选择某行
beginEditindex开始编辑某行
endEditindex结束编辑某行
cancelEditindex退出编辑某行
refreshRowindex刷新一行的数据
appendRowrow添加新行
deleteRowindex删除一行
getChangestypeGet changed rows since the last commit. The type parameter indicate which type changed rows, possible value is: inserted,deleted,updated,etc. When the type parameter is not assigned, return all changed rows.
acceptChangesnoneCommits all the changes data since it was loaded or since the last time acceptChanges was called.
rejectChangesnoneRolls back all the changes data since it was created, or since the last time acceptChanges was called.