JqGrid: paging int asp.net
https://www.codeproject.com/Articles/1118363/GridView-with-Server-Side-Filtering-Sorting-and-Pa
http://mvcgrid.net/download
https://github.com/joeharrison714/MVCGrid.Net
https://www.nuget.org/packages/PagedList.Mvc/
https://datatables.net/download/index
https://archive.codeplex.com/?p=jqmvcgrid
https://www.nuget.org/packages/jQuery.Grid/
https://github.com/atatanasov/gijgo
https://github.com/TroyGoode/PagedList
http://gijgo.com/grid
jadgrid.aspx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | <!DOCTYPE html> <!--HTML5 doctype--> <html> <head runat= "server" > <meta charset= "utf-8" > <meta name= "viewport" content= "width=device-width,initial-scale=1,user-scalable=0" > <title>JQGrid 测试分页用</title> <link href= "~/Styles/Site.css" rel= "stylesheet" type= "text/css" /> <script src= "JQGridReq/jquery-1.9.0.min.js" type= "text/javascript" ></script> <link href= "JQGridReq/jquery-ui-1.9.2.custom.css" rel= "stylesheet" type= "text/css" /> <script src= "JQGridReq/jquery.jqGrid.js" type= "text/javascript" ></script> <link href= "JQGridReq/ui.jqgrid.css" rel= "stylesheet" type= "text/css" /> <script src= "JQGridReq/grid.locale-cn.js" type= "text/javascript" ></script> <script type= "text/javascript" > $(function () { $( "#UsersGrid" ).jqGrid({ url: 'geovinHandler.ashx' , datatype: 'json' , height: 550, colNames: [ '序號' , '會員卡號' , '會員姓名' , '保證單號' , '會員登錄賬號' , '發佈時間' ], colModel: [ { name: 'LotteryId' , index: 'LotteryId' , width: 100, sortable: true }, { name: 'LotteryVipNo' , width: 100, sortable: true , editable: true }, { name: 'LotteryVipName' , width: 100, sortable: true , editable: true }, { name: 'LotteryGuaranteeNumber' , width: 100, sortable: true , editable: true }, { name: 'LotteryBranchAccount' , width: 100, sortable: true , editable: true }, { name: 'LotteryAddTime' ,formatter: "date" ,ormatoptions: { srcformat: "ISO8601Long" , newformat: "m/d/Y h:i A" }, width: 150, sortable: true } ], rowNum: 50, mtype: 'GET' , loadonce: true , rowList: [50, 100, 300], pager: '#UsersGridPager' , sortname: 'LotteryId' , viewrecords: true , sortorder: 'asc' , editurl: 'geovinHandler.ashx' , caption: '會員穫得中獎名單' }); $( "#UsersGrid" ).jqGrid( 'navGrid' , '#UsersGridPager' , { edit: true , add: true , del: true , search: true , searchtext: "Search" , addtext: "Add" , edittext: "Edit" , deltext: "Delete" }, { //EDIT // height: 300, // width: 400, // top: 50, // left: 100, // dataheight: 280, closeOnEscape: true , //Closes the popup on pressing escape key reloadAfterSubmit: true , drag: true , afterSubmit: function (response, postdata) { if (response.responseText == "" ) { $( this ).jqGrid( 'setGridParam' , { datatype: 'json' }).trigger( 'reloadGrid' ); //Reloads the grid after edit return [ true , '' ] } else { $( this ).jqGrid( 'setGridParam' , { datatype: 'json' }).trigger( 'reloadGrid' ); //Reloads the grid after edit return [ false , response.responseText] //Captures and displays the response text on th Edit window } }, editData: { EmpId: function () { var sel_id = $( '#UsersGrid' ).jqGrid( 'getGridParam' , 'selrow' ); var value = $( '#UsersGrid' ).jqGrid( 'getCell' , sel_id, 'LotteryId' ); return value; } } }, { closeAfterAdd: true , //Closes the add window after add 如何自定義添加窗口? afterSubmit: function (response, postdata) { if (response.responseText == "" ) { $( this ).jqGrid( 'setGridParam' , { datatype: 'json' }).trigger( 'reloadGrid' ) //Reloads the grid after Add return [ true , '' ] } else { $( this ).jqGrid( 'setGridParam' , { datatype: 'json' }).trigger( 'reloadGrid' ) //Reloads the grid after Add return [ false , response.responseText] } } }, { //DELETE closeOnEscape: true , closeAfterDelete: true , reloadAfterSubmit: true , closeOnEscape: true , drag: true , afterSubmit: function (response, postdata) { if (response.responseText == "" ) { $( "#UsersGrid" ).trigger( "reloadGrid" , [{ current: true }]); return [ false , response.responseText] } else { $( this ).jqGrid( 'setGridParam' , { datatype: 'json' }).trigger( 'reloadGrid' ); return [ true , response.responseText] } }, delData: { EmpId: function () { var sel_id = $( '#UsersGrid' ).jqGrid( 'getGridParam' , 'selrow' ); var value = $( '#UsersGrid' ).jqGrid( 'getCell' , sel_id, 'LotteryId' ); return value; } } }, { //SEARCH closeOnEscape: true }); }); </script> </head> <body> <form id= "form1" runat= "server" > <div> <table id= "UsersGrid" cellpadding= "0" cellspacing= "0" > </table> <div id= "UsersGridPager" > </div> </div> </form> </body> </html> |
geovinHandler.ashx:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | /// <summary> /// $codebehindclassname$ 的摘要说明 /// geovindu /// 20180128 /// 涂聚文 /// </summary> [WebService(Namespace = "http://tempuri.org/" )] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class geovinHandler : IHttpHandler { DuMembershipLotteryBLL bll = new DuMembershipLotteryBLL(); /// <summary> /// /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { HttpRequest request = context.Request; HttpResponse response = context.Response; System.Collections.Specialized.NameValueCollection forms = context.Request.Form; string strOperation = forms.Get( "oper" ); // response.Write(strOperation); string strResponse = string .Empty; string _search = request[ "_search" ]; string numberOfRows = request[ "rows" ]; string pageIndex = request[ "page" ]; string sortColumnName = request[ "sidx" ]; string sortOrderBy = request[ "sord" ]; int totalRecords; List<DuMembershipLotteryInfo> info = new List<DuMembershipLotteryInfo>(); if (strOperation == null ) { info = bll.SelectDuMembershipLotteryPaging(Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex), sortColumnName, sortOrderBy, out totalRecords); string output = BuildJQGridResults(info, Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex), Convert.ToInt32(totalRecords)); response.Write(output); } else if (strOperation == "del" ) { string strEmpId = forms.Get( "id" ).ToString(); //DeleteEmployee(strEmpId); bool del = false ; del = bll.DeleteDuMembershipLottery(Convert.ToInt32(strEmpId)); if (del) { strResponse = "删除成功" ; } context.Response.Write(strResponse); } else { string strOut = string .Empty; AddEdit(forms, info, out strOut); context.Response.Write(strOut); } } /// <summary> /// /// </summary> /// <param name="users"></param> /// <param name="numberOfRows"></param> /// <param name="pageIndex"></param> /// <param name="totalRecords"></param> /// <returns></returns> private string BuildJQGridResults(List<DuMembershipLotteryInfo> infos, int numberOfRows, int pageIndex, int totalRecords) { JQGridResults result = new JQGridResults(); List<JQGridRow> rows = new List<JQGridRow>(); foreach (DuMembershipLotteryInfo info in infos) { JQGridRow row = new JQGridRow(); row.id = info.LotteryId; row.cell = new string [6]; row.cell[0] = info.LotteryId.ToString(); row.cell[1] = info.LotteryVipNo; row.cell[2] = info.LotteryVipName; row.cell[3] = info.LotteryGuaranteeNumber; row.cell[4] = info.LotteryBranchAccount; row.cell[5] = info.LotteryAddTime.ToString(); rows.Add(row); } result.rows = rows.ToArray(); result.page = pageIndex; result.total = totalRecords / numberOfRows; result.records = totalRecords; return new JavaScriptSerializer().Serialize(result); } /// <summary> /// 添加或修改操作 /// </summary> /// <param name="forms"></param> /// <param name="collectionEmployee"></param> /// <param name="strResponse"></param> private void AddEdit(NameValueCollection forms, List<DuMembershipLotteryInfo> collectionInfo, out string strResponse) { string strOperation = forms.Get( "oper" ); string strEmpId = string .Empty; DuMembershipLotteryInfo info = new DuMembershipLotteryInfo(); info.LotteryVipNo = forms.Get( "LotteryVipNo" ).ToString(); info.LotteryVipName = forms.Get( "LotteryVipName" ).ToString(); info.LotteryGuaranteeNumber = forms.Get( "LotteryGuaranteeNumber" ).ToString(); info.LotteryBranchAccount = forms.Get( "LotteryBranchAccount" ).ToString(); info.LotteryAddTime = DateTime.Now; int saveok = 0; //string strdate = forms.Get("UpdateTime").ToString(); if (strOperation == "add" ) { string result = "0" ; strEmpId = (Convert.ToInt32(result) + 1).ToString(); saveok = bll.InsertDuMembershipLottery(info); if (saveok > 0) { strResponse = "record successfully added添加成功" ; } else { strResponse = "" ; } } else if (strOperation == "edit" ) { strEmpId = forms.Get( "EmpId" ).ToString(); //获取修改ID info.LotteryId = Convert.ToInt32(strEmpId); saveok=bll.UpdateDuMembershipLottery(info); if (saveok > 0) { strResponse = "record successfully updated修改成功" ; } else { strResponse = "" ; } } else { strResponse = "" ; } } /// <summary> /// /// </summary> public bool IsReusable { get { return false ; } } } |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
分类:
Ajax&JavaScript
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2013-01-30 Csharp: 打印設置字符之間的間距