转自:https://blog.csdn.net/u013178480/article/details/72358551
1 <code class="language-html"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <title>jQuery EasyUI</title> 6 <link rel="stylesheet" type="text/css" href="../themes/default/easyui.css"> 7 <link rel="stylesheet" type="text/css" href="../themes/icon.css"> 8 <script type="text/javascript" src="../jquery-1.4.4.min.js"></script> 9 <script type="text/javascript" src="../jquery.easyui.min.js"></script> 10 <script> 11 $(function(){ 12 $('#test').datagrid({ 13 title:'TestDataGrid',//列表名 14 iconCls:'icon-save', 15 600, 16 height:350, 17 nowrap: false, 18 striped: true, 19 collapsible:true, 20 url:'datagrid_data.json', //所连的Action名 21 sortName: 'code', 22 sortOrder: 'desc', 23 remoteSort: false, 24 idField:'code', 25 frozenColumns:[[ 26 {field:'ck',checkbox:true}, 27 {title:'序列',field:'code',80,sortable:true} 28 ]], 29 columns:[[ 30 {title:'内容',colspan:3}, 31 {field:'opt',title:'操作',100,align:'center', rowspan:2, 32 formatter:function(value,rec){ 33 return '<span style="color:red">编辑 删除e</span>'; 34 } 35 } 36 ],[ 37 {field:'writer',title:'姓名',120}, 38 {field:'addr',title:'住址',120,rowspan:2,sortable:true, 39 sorter:function(a,b){ 40 return (a>b?1:-1); 41 } 42 }, 43 {field:'content',title:'说说',150,rowspan:2} 44 ]], 45 pagination:true, 46 rownumbers:true, 47 toolbar:[{ 48 text: '输入框1<input type="text" id="userAccount"/>输入框2<input type="text" id="identityNum"/>' 49 }, { 50 text: '输入框3<input type="text" id="username"/>' 51 }, { 52 id: 'btnAddPeopleSetId', 53 text: '这是toolbar输入框', 54 iconCls: 'icon-add', 55 handler: function(){ 56 inputToobar(); 57 } 58 }] 59 }); 60 var p = $('#test').datagrid('getPager'); 61 if (p){ 62 $(p).pagination({ 63 onBeforeRefresh:function(){ 64 alert('before refresh'); 65 } 66 }); 67 } 68 }); 69 70 </script> 71 </head> 72 <body> 73 <h1>DataGrid</h1> 74 <table id="test"></table> 75 76 </body> 77 </html> 78 </code>