本文主要是介绍laypage这个分页插件怎么用?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/// <summary>/// 数据分页/// </summary>/// <param name="viewName">表名</param>/// <param name="fieldName">字段</param>/// <param name="pageSize">默认20</param>/// <param name="pageNo">页数</param>/// <param name="orderString">排序</param>/// <param name="whereString">可选</param>/// <param name="recordTotal">总数</param>/// <returns></returns>public DataTable GetDataPager(string viewName, string fieldName, int pageSize, int pageNo, string orderString, string whereString, ref int recordTotal){using (DbContext Entities = GetDbContext()){DataSet ds = new DataSet();string connectionString = Entities.Database.Connection.ConnectionString;SqlConnection conn = new System.Data.SqlClient.SqlConnection();conn.ConnectionString = connectionString;if (conn.State != ConnectionState.Open){conn.Open();}try{SqlCommand cmd = new SqlCommand();cmd.Connection = conn;cmd.CommandText = "usp_DataPager";cmd.CommandType = CommandType.StoredProcedure;SqlParameter[] paras = new SqlParameter[7];paras[0] = new SqlParameter("viewName", viewName);paras[1] = new SqlParameter("fieldName", fieldName);paras[2] = new SqlParameter("pageSize", pageSize);paras[3] = new SqlParameter("pageNo", pageNo);paras[4] = new SqlParameter("orderString", orderString);if (whereString.Trim() == ""){whereString = " 1=1 ";}paras[5] = new SqlParameter("whereString", whereString);paras[5].Size = Int32.MaxValue;paras[6] = new SqlParameter("recordTotal", recordTotal);paras[6].Direction = ParameterDirection.Output;cmd.Parameters.AddRange(paras);SqlDataAdapter adapter = new SqlDataAdapter(cmd);adapter.Fill(ds);recordTotal = Int32.Parse(paras[6].Value == null ? "0" : paras[6].Value.ToString());return ds.Tables[0];}catch (Exception ex){throw ex;}finally { conn.Close(); }}}public DataTable GetInquireListByPage(ref int pageCount, string sortCode = "", string baseName = "", int page = 1, int pageSize = 15){string strSql = " RL_InquireResource resourc inner join RL_InquireSort sort on resourc.InquireSortCode=sort.InquireSortCode ";string strWhere = " 1=1 and resourc.Del='0'";if (!string.IsNullOrEmpty(sortCode)){strWhere += string.Format(" And sort.InquireSortCode={0}", sortCode);}if (!string.IsNullOrEmpty(baseName)){strWhere += string.Format(" and (resourc.DoctorQuestion like '%{0}%' or resourc.keyword like '%{0}%' or resourc.KeywordSpelling like '%{0}%')", baseName);}return new RL_InquireResourceB().GetDataPager(strSql, " resourc.*,sort.InquireSortName ", pageSize, page, " HealthExamItemNum ", strWhere, ref pageCount);}GetResource: function (sortCode) {tempmodel.page.pageindex = 1;var baseName = $("#txtSearch").val();$.getJSON("/API/FTAPI.ashx", { "Action": "GETHEALTHEXAMPAGE", "ParamData": sortCode, "baseName": baseName, "pageIndex": tempmodel.page.pageindex, "pageCount": tempmodel.page.pageCount }, function (msg) {tempmodel.resourceData.clear();tempmodel.resourceData.pushArray(msg.Result);tempmodel.page.total = msg.Result1;laypage({cont: "pageDiv",pages: Math.ceil(parseInt(msg.Result1) / parseInt(tempmodel.page.pageCount)),curr: tempmodel.page.pageindex,skin: 'molv',jump: function (e) {if (e.curr != tempmodel.page.pageindex) {$.getJSON("/API/FTAPI.ashx", { "Action": "GETHEALTHEXAMPAGE", "ParamData": sortCode, "baseName": baseName, "pageIndex": e.curr, "pageCount": tempmodel.page.pageCount }, function (msg) {tempmodel.resourceData.clear();tempmodel.resourceData.pushArray(msg.Result);});}tempmodel.page.pageindex = e.curr;}})})}分页:<div id="pageDiv"></div>
这篇关于laypage这个分页插件怎么用?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!