ruler20092013-01-07 01:42:37 |
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" " <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "> <title>complex datagrid-jquery Easyui demo</title> <link rel= "stylesheet" type= "Text/css" href= ". /themes/default/easyui.css "> <link rel= "stylesheet" type= "Text/css" href= ". /themes/icon.css "> <link rel= "stylesheet" type= "Text/css" href= "Demo.css" > <script type= "Text/javascript" src= ". /jquery-1.6.min.js "></script> <script type= "Text/javascript" src= ". /jquery.easyui.min.js "></script> <script> $ (function () { $ (' #test '). DataGrid ({ Title: ' My DataGrid ', Iconcls: ' Icon-save ', width:700, HEIGHT:350, Nowrap:false, Striped:true, Collapsible:true, URL: ' Datagrid_data.json ', Sortname: ' Code ', SortOrder: ' Desc ', Remotesort:false, 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:220,rowspan:2,sortable:true, Sorter:function (A, b) { return (A>B?1:-1); } }, {field: ' Col4 ', title: ' Col41 ', Width:150,rowspan:2} ]], Pagination:true, Rownumbers:true, toolbar:[{ ID: ' Btnadd ', Text: ' Add ', Iconcls: ' Icon-add ', Handler:function () { $ (' #btnsave '). LinkButton (' Enable '); Alert (' Add ') } },{ ID: ' Btncut ', Text: ' Cut ', Iconcls: ' Icon-cut ', Handler:function () { $ (' #btnsave '). LinkButton (' Enable '); Alert (' Cut ') } },‘-‘,{ ID: ' Btnsave ', Text: ' Save ', Disabled:true, Iconcls: ' Icon-save ', Handler:function () { $ (' #btnsave '). LinkButton (' disable '); Alert (' Save ') } }] }); var p = $ (' #test '). DataGrid (' Getpager '); $ (P). Pagination ({ Onbeforerefresh:function () { Alert (' before Refresh '); } }); }); function Resize () { $ (' #test '). DataGrid (' resize ', { width:700, height:400 }); } function getselected () { var selected = $ (' #test '). DataGrid (' getselected '); if (selected) { Alert (selected.code+ ":" +selected.name+ ":" +selected.addr+ ":" +selected.col4 "); } } 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); } function MergeCells () { $ (' #test '). DataGrid (' MergeCells ', { Index:2, Field: ' Addr ', Rowspan:2, Colspan:2 }); } </script> <body> <div class= "Demo-info" > <div class= "Demo-tip icon-tip" ></div> <div>click the button to doing actions with datagrid.</div> </div>
<div style= "margin:10px 0;" > <a href= "#" onclick= "getselected ()" >GetSelected</a> <a href= "#" onclick= "Getselections ()" >GetSelections</a> <a href= "#" onclick= "SelectRow ()" >SelectRow</a> <a href= "#" onclick= "Selectrecord ()" >SelectRecord</a> <a href= "#" onclick= "Unselectrow ()" >UnselectRow</a> <a href= "#" onclick= "Clearselections ()" >ClearSelections</a> <a href= "#" onclick= "resize ()" >Resize</a> <a href= "#" onclick= "MergeCells ()" >MergeCells</a> </div>
<table id= "Test" ></table>
</body>
can be achieved, |