LigerUI 分頁 MVC

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.