mvc ligerGrid 分页查询方法

<script type="text/javascript"> 
        $(f_initGrid);
        var manager, GridList;
        function f_initGrid() {
            GridList = manager = $("#maingrid").ligerGrid({
                checkbox: true,                 
             
                columns: [
                { display: ‘产品编号‘, name: ‘ItemNO‘, editor: { type: ‘text‘ }, frozen: true },
                { display: ‘产品名称‘, name: ‘Name‘, editor: { type: ‘text‘ } },
                {display: ‘产品类别‘, name: ‘CateIds‘, editor: { type: ‘text‘ }, render: function (rowdata, rowindex, value) {
                        var tabCell = value;                      
                        $.ajax({
                            type: "post", //使用get方法访问后台
                            dataType:"json", //返回json
                            async: false, //true 异步  false为同步请求 
                            url: "/product/Get_ProductType?pid="+value.toString(),                                                    
                            success: function (msg) {
                                tabCell = msg.Msg;
                            }                            
                        });
                        return tabCell;
                    }
                },
                { display: ‘产品品牌‘, name: ‘Brand‘, editor: { type: ‘text‘ } },
                { display: ‘产品状态‘, name: ‘Status‘, type: ‘text‘, editor: { type: ‘int‘ } },
                //{ display: ‘添加时间‘, name: ‘Age‘, width: ‘10%‘, type: ‘text‘, editor: { type: ‘text‘ } },
              
                { display: ‘市场价格‘, name: ‘State‘, editor: { type: ‘text‘ } },
     
                {
                    display: ‘操作‘, isSort: false, width: 200, render: function (rowdata, rowindex, value) {
                        var h = "";
                        if (!rowdata._editing) {
                            h += "<a href=‘javascript:f_open(" + rowindex + ")‘>详细信息</a>";
                            h += "<a href=‘javascript:deleteRow(" + rowindex + ")‘>上架</a> ";
                            h += "<a href=‘javascript:deleteRow(" + rowindex + ")‘>下架</a> ";
                            h += "<a href=‘javascript:deleteRow(" + rowindex + ")‘> 删除</a> ";
                        }
                        else {
                            h += "<a href=‘javascript:endEdit(" + rowindex + ")‘>提交</a> ";
                            h += "<a href=‘javascript:cancelEdit(" + rowindex + ")‘>取消</a> ";
                        }
                        return h;
                    }
                }
                ],             
                url: "/Product/SearchProducts",
                parms: [{ name: ‘key_Name‘, value: "" }, { name: ‘key_price1‘, value: "" }, { name: ‘key_price2‘, value: "" }],             
                rownumbers: true,
                pageSize: 20,
                pageSizeOptions: [10, 15, 20, 25, 30],                        
                width: ‘100%‘,
                height: ‘100%‘
            });
            $("#Btn_Search").click(search_Product);
        }     
   //查询
        function search_Product() {          
            GridList.setParm("key_Name", $("#Txt_Name").val());
            GridList.setParm("key_price1", $("#key_price1").val());
            GridList.setParm("key_price2", $("#key_price2").val());            
            GridList.loadData("/Product/SearchProducts");
            //loadData(parm)  parm: 1,Function过滤函数 2,Bool是否加载服务器数据 3,Object data  加载数据  
        }
    </script>
 #region 查询产品
        //获取供应商下面的产品列表
        public ActionResult SearchProducts()
        {
            //List<BasicProductDto> list = ServiceLocator.Create<YJY.Supply.Product.IProductService>().ListProduct(SysHelper.GetUserID());
            //var gridData = new { Rows = list, Total = list.Count };
            //return Json(gridData);

            //排序字段
            string sortName = "";
            if (Request.Params["sortname"] != null)
                sortName = Request.Params["sortname"];
            //排序方式
            string sortOrder = "";
            if (Request.Params["sortorder"] != null)
                sortOrder = Request.Params["sortorder"];
            //当前页面
            int currentPageIndex = 1;
            if (Request.Params["page"] != null)
                currentPageIndex = Convert.ToInt32(Request.Params["page"]);
            //当前页面大小
            int pageSize =20;
            if (Request.Params["pagesize"] != null)
                pageSize = Convert.ToInt32(Request.Params["pagesize"]);
            //产品名称
            string key_Name = "";
            if (Request.Params["key_Name"] != null)
                key_Name = Request.Params["key_Name"];
            //最低价
            string key_price1 = "";
            if (Request.Params["key_price1"] != null)
                key_price1 = Request.Params["key_price1"];
            //最高价
            string key_price2 = "";
            if (Request.Params["key_price2"] != null)
                key_price2 = Request.Params["key_price2"];

            SearchProductDto searchDto = new SearchProductDto();
            searchDto.SupplierId = SysHelper.GetUserID();//供应商id 
            searchDto.Name = key_Name;
            searchDto.BeginPrice = Convert.ToDecimal(key_price1);
            searchDto.EndPrice = Convert.ToDecimal(key_price2);
            int recordCount=0;
            List<BasicProductDto> list = ServiceLocator.Create<YJY.Supply.Product.IProductService>().QueryProducts(searchDto, currentPageIndex, pageSize, out recordCount);
            var gridData = new { Rows = list,Total=recordCount};
            return Json(gridData);
        }
        #endregion


mvc ligerGrid 分页查询方法,布布扣,bubuko.com

mvc ligerGrid 分页查询方法

上一篇:解决Python中ZipFile解压文件名中文乱码的问题


下一篇:MySQL数据类型 - 空间数据类型(5)