本文实例讲述了jquery easyui datagrid实现增加,修改,删除的方法。分享给大家供大家参考,具体如下:
页面:
<body> <form id="form1" runat="server"> <table id="tt"> </table> </form> </body>
引用的JS:
<link rel="stylesheet" type="text/css" href="/script/themes/default/easyui.css" /> <link rel="stylesheet" type="text/css" href="/script/themes/icon.css" /> <script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.4.2.min.js">JS:
<script type="text/javascript"><!-- $(function(){ $('#tt').datagrid({ width:810, height:400, idField:'xsbh', url:'studentHandler.ashx', singleSelect:true, columns:[[ {field:'xsbh',title:'编号',width:80}, {field:'UserName',title:'姓名',width:100}, {field:'Sex',title:'性别',width:30}, {field:'SchoolYear',title:'年份',width:50}, {field:'opt',title:'操作',width:100,align:'center', formatter:function(value,rec,index){ var s = '<a href="#" mce_href="#" onclick="view(\''+ rec.xsbh + '\')">查看</a> '; var e = '<a href="#" mce_href="#" onclick="edit(\''+ rec.xsbh + '\')">编辑</a> '; var d = '<a href="#" mce_href="#" onclick="del(\''+ index +'\')">删除</a> '; return s+e+d; } } ]], toolbar:[{ text:'增加',iconCls:'icon-add',handler:function(){ window.location.href='StuAdd.aspx'; } }, {text:'导入',iconCls:'icon-add',handler:function(){ window.location.href='StuImport.aspx' } }, {text:'查找',iconCls:'icon-search'} ], pagination:true }); }) function view(bh) //转到查看页面 { window.location.href='StuView.aspx"操作"的跨行,一定要带上field:'opt',当然,field可以是任何值,这个值不用从数据库中绑定,随便取.如果没有field的话,会弹出 "rowspan为空或不是对象"的错误获取数据和分页ashx:
using System; using System.Web; using System.Data; using System.Text; public class studentHandler : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; DataSet ds = new DataSet(); //点击datagrid的分页按钮,自动向后台发送2个参数,rows和page,代表每页记录数和页索引 int row = int.Parse(context.Request["rows"].ToString()); int page = int.Parse(context.Request["page"].ToString()); ds = GetContent(row, page); string text =json.Dataset2Json(ds); context.Response.Write(text); } private DataSet GetContent(int pagesize,int pageindex) { Graduate.BLL.Student bll = new Graduate.BLL.Student(); return bll.GetList(pagesize, pageindex); } public bool IsReusable { get { return false; } } }删除ashx
using System; using System.Web; using System.Web.SessionState; public class delHandler : IHttpHandler,IRequiresSessionState { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string id = context.Request["id"].ToString(); string type = context.Request["type"].ToString(); switch (type) { case "stu": Graduate.BLL.Student stubll = new Graduate.BLL.Student(); stubll.Delete(id, HttpContext.Current.Session["username"].ToString(), HttpContext.Current.Session["usertype"].ToString()); break; default: break; } } public bool IsReusable { get { return false; } } }IRequiresSessionState 是因为用到了服务器端的session,没有用到的话可以去掉
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jquery中Ajax用法总结》、《jQuery表格(table)操作技巧汇总》、《jQuery拖拽特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》、《jquery选择器用法总结》及《jQuery常用插件及用法总结》
希望本文所述对大家jQuery程序设计有所帮助。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。