首页 > 代码库 > LigerUI 分页 MVC
LigerUI 分页 MVC
Javascirpt代码
$("#showData").ligerGrid({ columns: [ { display: ‘编号‘, name: ‘L_ID‘, align: ‘center‘, width: 70 }, {display: ‘时间‘, name: ‘L_TIME‘, minWidth: 120, type: ‘date‘, format: ‘yyyy-MM-dd HH:mm‘ }, { display: ‘经度‘, name: ‘L_LONGITUDE‘, width: 90, align: ‘left‘ }, { display: ‘纬度‘, name: ‘L_LATITUDE‘, width: 80, align: ‘left‘ }, { display: ‘强度‘, name: ‘L_CURRENT‘, width: 50 }, { display: ‘回击数‘, name: ‘L_RETIMES‘, width: 50 }, { display: ‘定位站数‘, name: ‘L_STATIONNUM‘, width: 50 } ], //绑定相应的列的头部,参数可以自己按照需求设置 //data: dataList, //数据 url: ‘../../LightningSearch/GetLightningByTime?stime=‘ + $("#txtStime").val() + ‘&etime=‘ + $("#txtEtime").val() + ‘‘, pageSizeOptions: [10, 20,30,], pageSize: 15, //每一页显示多少条数据 sortName: ‘L_ID‘, //以那一列排序 width: ‘auto‘, //宽度 height: ‘515‘, dateFormat: ‘yyyy-MM-dd HH:mm‘, checkbox: false//是否有选择框 });
ActionResult
public ActionResult GetLightningByTime() { //当前页 int page = Convert.ToInt32(Request.Params["page"]); //每页显示的记录数 int pageSize = Convert.ToInt32(Request.Params["pagesize"]); string stime = Request.Params["stime"].ToString(); string etime = Request.Params["etime"].ToString(); string _stime = stime.Replace("-", "").Replace(":", "").Replace(" ", "") + "00"; string _etime = etime.Replace("-", "").Replace(":", "").Replace(" ", "") + "59"; LightningL19XX list = helper.GetLightningByTime(_stime, _etime, page, pageSize); int count = list._Count; List<L19XX> lightning = list._L19XX; var gridData = http://www.mamicode.com/new { Rows = lightning, Total = count }; return Json(gridData); }
分页(数据库的表结构一致,表名为"L"+年份)
public LightningL19XX GetLightningByTime(string stime, string etime, int page, int pageSize) { List<L19XX> list = new List<L19XX>(); int _stime = int.Parse(stime.Substring(0, 4)); int _etime = int.Parse(etime.Substring(0, 4)); string _TableName = "L"; int _count = _etime - _stime; string sql = ""; for (int i = _stime; i <= _etime; i++) { if (_etime > i) { sql += " select * from " + _TableName + i.ToString() + " where L_TIME>=" + stime + " and L_TIME<=" + etime + " union "; } else { sql += " select * from " + _TableName + i.ToString() + " where L_TIME>=" + stime + " and l_TIME<=" + etime + " "; } } int count = entity.Database.SqlQuery<L19XX>(sql).ToList().Count; list = entity.Database.SqlQuery<L19XX>(sql).ToList().Skip((page - 1) * pageSize).Take(pageSize).ToList(); if (list.Count==0) { L19XX l = new L19XX() { L_ALTITUDE = null, L_CURRENT = null, L_RETIMES = null, L_LONGITUDE = null, L_TIME = null, L_LATITUDE = null, L_ID = null }; list.Add(l); } LightningL19XX lightning = new LightningL19XX() { _L19XX = list, _Count = count }; return lightning; }
LigerUI 分页 MVC
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。