mvc ligerGrid 分页查询方法

http://blog.csdn.net/lybwwp/article/details/22284713


<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' } },
{ 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值