easyui的一些常用类

  1. .net分页。

分页类(可以作为查询类的父类)

    public class PageQueryParam
    {
        public int Rows { get; set; }

        public int Page { get; set; }


        public int Offset { get
            {
                return Rows * (Page - 1); 
            }
        }




        public PageQueryParam()
        {

        }
        public PageQueryParam(int Rows, int Page)
        {
            this.Rows = Rows;
            this.Page = Page;
        }

       
        
    }

查询结果类:

eg:

 var Query = db.Query<AmPartTraceBack0201Detail>(new PageInfo(param.Page, param.Rows), sql, param).ToList();
 public class PageQueryResult<T> 
    {
        [JsonProperty("total", NullValueHandling = NullValueHandling.Ignore)]
        public int Total { get; set; }

        [JsonProperty("rows", NullValueHandling = NullValueHandling.Ignore)]
        public List<T> Rows { get; set; }

        [JsonProperty("footer", NullValueHandling = NullValueHandling.Ignore)]
        public List<T> Footer { get; set; }

        public PageQueryResult()
        {
            this.Rows = new List<T>();
        }
        public PageQueryResult(int total, List<T> rows)
        {
            this.Total = total;
            this.Rows = rows;
        }
        public PageQueryResult(int total, List<T> rows,List<T> footer)
        {
            this.Total = total;
            this.Rows = rows;
            this.Footer = footer;
        }


        //public PageQueryResult<dynamic>  toDynamic ()
        //{
        //    this.Rows.ToList<dynamic>();
        //}



    }

    public class PageQueryDtResult
    {
        [JsonProperty("total", NullValueHandling = NullValueHandling.Ignore)]
        public int Total { get; set; }

        [JsonProperty("rows", NullValueHandling = NullValueHandling.Ignore)]
        public DataTable Rows { get; set; }

        [JsonProperty("footer", NullValueHandling = NullValueHandling.Ignore)]
        public DataTable Footer { get; set; }

        public PageQueryDtResult()
        {
            this.Rows = new DataTable();
        }
        public PageQueryDtResult(int total, DataTable rows)
        {
            this.Total = total;
            this.Rows = rows;
        }
    }

    public class PageQueryResult
    {
        [JsonProperty("total", NullValueHandling = NullValueHandling.Ignore)]
        public int Total { get; set; }

        [JsonProperty("rows", NullValueHandling = NullValueHandling.Ignore)]
        public List<object> Rows { get; set; }

        [JsonProperty("footer", NullValueHandling = NullValueHandling.Ignore)]
        public List<object> Footer { get; set; }

        public PageQueryResult()
        {
            this.Rows = new List<object>();
        }
        public PageQueryResult(int total)
        {
            this.Total = total;
            this.Rows = new List<object>();
        }
    }

封装类:

eg:

return new PageQueryResult<AmPartTraceBack0201Detail>(db.Count(sql,param), Query);
 public class PageInfo
    {
        #region 私有变量

        private int _pageSize = 20;
        private int _currentPage = 1;

        #endregion

        #region 公开属性

         /// <summary>
        /// 页长
        /// </summary>
        public int PageSize
        {
            get { return _pageSize; }
            set
            {
                if (value <= 0) throw new ArgumentOutOfRangeException("值必须大于0!");
                _pageSize = value;
            }
        }

        /// <summary>
        /// 当前面
        /// </summary>
        public int CurrentPage
        {
            get { return _currentPage; }
            set
            {
                if (value <= 0) throw new ArgumentOutOfRangeException("值必须大于0!");
                _currentPage = value;
            }
        }

        #endregion

        #region 构造函数

        public PageInfo(int curPage, int pageSize)
        {
            this.CurrentPage = curPage;
            this.PageSize = pageSize;
        }
  
        #endregion

        #region 重写方法

        #endregion

        #region 公开方法

        #endregion

        #region 辅助方法

        #endregion
    }

controller;

        [JsonException]
        public JsonResult Query0201(AmPartTraceBack0201Query query)
        {
            var data = new AmPartTraceBack0201Service().Query(query);
            return Json(data);
        }

前端接收:

           <div data-options="region:'center',title:'显示列表',iconCls:'icon-search'" style="padding:5px">
                <!--table-easyui-->
                <table id="@ViewBag.PageId-table-easyui"
                       data-options="
            singleSelect:false,
            pagination: true,
            pageSize: 60,
            pageList: [60, 120, 180, 240, 300]">
                    <thead data-options="frozen:true">
                        <tr>
                            <th data-options="field:'ck',checkbox:true"></th>
                            <th data-options="field:'PlanDate',width:100,align:'center'">计划日</th>
                            <th data-options="field:'RealDate',width:100,align:'center'">生产日</th>
                            <th data-options="field:'MissionNo',width:120,align:'center'">变速箱号</th>
                        </tr>
                    </thead>
                    <thead>
                        <tr>
                            <th data-options="field:'LineNm',width:120,align:'center'">生产线</th>
                            <th data-options="field:'ModelNm',width:120,align:'center'">机种部品</th>
                            <th data-options="field:'ChaSuQiKeTi',width:120,align:'center'">差速器壳体</th>
                            <th data-options="field:'ChaSuQiChiLun',width:120,align:'center'">差速器齿轮</th>
                            <th data-options="field:'ZuiZhongChuanDongZhou',width:120,align:'center'">最终传动轴</th>
                            <th data-options="field:'DiErJianSuCongDongChiLun',width:120,align:'center'">第二减速从动齿轮</th>
                            <th data-options="field:'JingMiGuoLvQi',width:120,align:'center'">精密过滤器</th>
                            <th data-options="field:'DrDaiLun',width:120,align:'center'">DR带轮</th>
                            <th data-options="field:'DnDaiLun',width:120,align:'center'">DN带轮</th>
                            <th data-options="field:'DrHuoSaiGai',width:120,align:'center'">DR活塞盖</th>
                            <th data-options="field:'CongDongLianLun',width:120,align:'center'">从动链轮</th>
                            <th data-options="field:'LianTiao',width:120,align:'center'">链条</th>
                            <th data-options="field:'DrHuoSai_A',width:120,align:'center'">DR活塞A</th>
                            <th data-options="field:'XiaoChuQiGai',width:120,align:'center'">消除器盖</th>
                            <th data-options="field:'GangDai',width:120,align:'center'">钢带</th>
                            <th data-options="field:'CreateDate',width:150,align:'center',hidden:true">创建时间</th>
                            <th data-options="field:'UpdateUser',width:80,align:'center'">最后修改人</th>
                            <th data-options="field:'UpdateDate',width:150,align:'center'">最后最后时间</th>
                        </tr>
                    </thead>
                </table>
            </div>

前端js:

//查询
                    query : function () {
                        var $form = $("#@ViewBag.PageId-form-query");
                        var $datagrid = $('#@ViewBag.PageId-table-easyui');
                        if ($form.form("validate")) {
                            var queryParams = $form.serializeObject();
                            $datagrid.datagrid('options').queryParams = queryParams;
                            $datagrid.datagrid('reload');
                        }
                    },          

                    //查询
                    $("#@ViewBag.PageId-btn-query").click(function () {
                        page.query();
                    });


//datagrid事件初始化
            $('#@ViewBag.PageId-table-easyui').datagrid({
                url: urls.query,
                onLoadSuccess: function (data) {
                    $('#@ViewBag.PageId-table-easyui').datagrid('fixRownumber');
                },

            });

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值