LigerUI 分页 MVC_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > LigerUI 分页 MVC

LigerUI 分页 MVC

 2014/9/18 18:14:12  xiaowei子渝  程序员俱乐部  我要评论(0)
  • 摘要:Javascirpt代码$("#showData").ligerGrid({columns:[{display:'编号',name:'L_ID',align:'center',width:70},{display:'时间',name:'L_TIME',minWidth:120,type:'date',format:'yyyy-MM-ddHH:mm'},{display:'经度',name:'L_LONGITUDE',width:90,align:'left'},{display:'纬度'
  • 标签:MVC

Javascirpt代码

class="code_img_closed" src="/Upload/Images/2014091818/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('8eaac227-0834-4a4a-9e31-034205afe39e',event)" src="/Upload/Images/2014091818/2B1B950FA3DF188F.gif" alt="" />
$("#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

 

上一篇: 线程系列01,前台线程,后台线程,线程同步 下一篇: 没有下一篇了!
发表评论
用户名: 匿名