JQuery easyui

  1. <body>  
  2.     <form id="form1" runat="server">  
  3.     <table id="tt">  
  4.           
  5.     </table>  
  6.       
  7.     
  8.     </form>  
  9. </body>  

引用的JS:

  1. <link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/script/themes/default/easyui.css" />  
  2.     <link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/script/themes/icon.css" />  
  3.     <script type="text/javascript" src="http://www.cnblogs.com/script/jquery-1.4.2.min.js" </script>  
  4.     <script type="text/javascript" src="http://www.cnblogs.com/script/jquery.easyui.min.js" </script>  
  5.     <script type="text/javascript" src="http://www.cnblogs.com/script/locale/easyui-lang-zh_CN.js" mce></script>   

JS:

  1. <script type="text/javascript"><!--  
  2.         $(function(){  
  3.             $('#tt').datagrid({  
  4.                 width:810,  
  5.                 height:400,  
  6.                 idField:'xsbh',  
  7.                 url:'studentHandler.ashx',  
  8.                 singleSelect:true,  
  9.                 columns:[[  
  10.                    {field:'xsbh',title:'编号',width:80},  
  11.                   {field:'UserName',title:'姓名',width:100},  
  12.                   {field:'Sex',title:'性别',width:30},  
  13.                   {field:'SchoolYear',title:'年份',width:50},  
  14.                   {field:'opt',title:'操作',width:100,align:'center',  
  15.                     formatter:function(value,rec,index){  
  16.                         var s = '<a href="#" mce_href="#" onclick="view(\''+ rec.xsbh + '\')">查看</a> ';  
  17.                         var e = '<a href="#" mce_href="#" onclick="edit(\''+ rec.xsbh + '\')">编辑</a> ';  
  18.                         var d = '<a href="#" mce_href="#" onclick="del(\''+ index +'\')">删除</a> ';  
  19.                         return s+e+d;  
  20.                     }  
  21.                   }  
  22.                 ]],  
  23.                 toolbar:[{  
  24.                     text:'增加',iconCls:'icon-add',handler:function(){  
  25.                         window.location.href='StuAdd.aspx';  
  26.                     }  
  27.                 },  
  28.                 {text:'导入',iconCls:'icon-add',handler:function(){  
  29.                     window.location.href='StuImport.aspx'  
  30.                     }  
  31.                 },  
  32.                 {text:'查找',iconCls:'icon-search'}  
  33.                 ],  
  34.                pagination:true  
  35.             });  
  36.         })  
  37.           
  38.           function view(bh)  //转到查看页面  
  39.             {  
  40.                 window.location.href='StuView.aspx?id='+bh+'&page=stu';  
  41. //              var row = $('#tt').datagrid('getSelected');  
  42. //               if(row)  
  43. //               {  
  44. //                  alert(row.xsbh);  
  45. //               }  
  46.             }  
  47.           function edit(bh)  //转到编辑页面  
  48.           {  
  49.                 window.location.href='StuEdit.aspx?id='+bh;  
  50.           }  
  51.             
  52.           function del(index){  //删除操作  
  53.             $.messager.confirm('确认','确认删除?',function(row){  
  54.                 if(row){  
  55.                     var selectedRow = $('#tt').datagrid('getSelected');  //获取选中行  
  56.                     $.ajax({  
  57.                         url:'delHandler.ashx?id='+selectedRow.xsbh+'&type=stu',    
  58. //加了个type,作用是以后不管什么删除,都可以转到这个ashx中处理  
  59.                         success:function(){alert('删除成功');}  
  60.                     });  
  61.                     $('#tt').datagrid('deleteRow',index);  
  62.                 }  
  63.             })  

相关推荐