標籤:style blog http color io os java ar for
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//是否有選擇框 });View Code
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 = new { Rows = lightning, Total = count }; return Json(gridData); }View Code
分頁(資料庫的表結構一致,表名為"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; }View Code
LigerUI 分頁 MVC