jQuery MiniUI

 找回密码
 立即注册
查看: 1477|回复: 3
打印 上一主题 下一主题

datagrid分页问题 [复制链接]

Rank: 3Rank: 3

跳转到指定楼层
楼主
发表于 2014-2-17 10:08:31 |只看该作者 |倒序浏览
public void SearchSupplier()
    {
        string plusid = Request["PlusId"]; string json;
        int pageIndex = Convert.ToInt32(Request["pageIndex"]);
        int pageSize = Convert.ToInt32(Request["pageSize"]);
        int i; int j;
        json = new JavaScriptSerializer().Serialize(supplinfo.GetPageSupplier(pageSize,pageIndex,Convert.ToInt32(plusid),out i,out j));
        i=0;j=0;
        //json = new JavaScriptSerializer().Serialize(supplinfo.GetSupplierBuPlusId(Convert.ToInt32(plusid)));
        Response.Write(json);
    }
分页代码,其中pageIndex始终为0,无法得到pageIndex,
前台代码 grid.load({ PlusId: e.node.id });
改为grid.reload({ PlusId: e.node.id });在前台什么都不显示

Rank: 8Rank: 8

沙发
发表于 2014-2-17 10:18:30 |只看该作者
pageIndex 为0 说明已经获取到了啊, 第一页就是0

grid.reload({ PlusId: e.node.id }) 没有这种写法

只有grid.load(obj)

刷新带参数,也调用grid.load()

Rank: 3Rank: 3

板凳
发表于 2014-2-17 16:01:06 |只看该作者
factory 发表于 2014-2-17 10:18
pageIndex 为0 说明已经获取到了啊, 第一页就是0

grid.reload({ PlusId: e.node.id }) 没有这种写法

create  proc [dbo].[p_propage]
@pagecount int,@index int,@id int,@type varchar(10),@sumcount int output,@counts int output
as
begin
declare @sum int
select @sum=COUNT(*) from t_productPrice
if(@sum%@pagecount=0)
select @sumcount=@sum/@pagecount
else
select @sumcount=@sum/@pagecount+1
select @counts=@index
select top (@pagecount) * from t_productPrice where ID not in
(select top ((@pagecount)*(@index-1)) ID from t_productPrice) and plusid=@id and PType=@type
end
GO
我用存储过程分页,这是代码
  public List<SupplierInfo> GetPageSupplier(int pagecount, int index, int id,out int sumpage, out int count)
    {
        List<SupplierInfo> list = new List<SupplierInfo>();
        SupplierInfo info = null;
        string sql = "p_prosupplier";
        SqlParameter[] p = new SqlParameter[5]
        {
            new SqlParameter("@pagecount",pagecount),
            new SqlParameter("@index",index),
            new SqlParameter("@id",id),
            new SqlParameter("@sumcount",SqlDbType.Int),//输出参数
            new SqlParameter("@counts",SqlDbType.Int)
        };

        p[3].Direction = ParameterDirection.Output;
        p[4].Direction = ParameterDirection.Output;
        using (SqlDataReader reader = SqlHelper.SqlData(sql, CommandType.StoredProcedure, p))
        {
            while (reader.Read())
            {
                info = new SupplierInfo();
                //info = new SupplierInfo();
                info.Id = Convert.ToInt32(reader[0]);
                info.Supplier = reader[1].ToString();
                info.SupplierNumber = reader[2].ToString();
                info.ProdColorQty = Convert.ToInt32(reader[3]);
                info.ProdQty = Convert.ToInt32(reader[4]);
                info.SampleColorQty = Convert.ToInt32(reader[5]);
                info.PlusId = Convert.ToInt32(reader[6]);
                info.SmapleQty = Convert.ToInt32(reader[7]);
                info.SampleCycle = Convert.ToInt32(reader[8]);
                info.Remark = reader[9].ToString();
                info.UserName = reader[10].ToString();
                info.DateTimes = Convert.ToDateTime(reader[11]);
                list.Add(info);
            }
        }
        sumpage = Convert.ToInt32(p[3].Direction);
        count = Convert.ToInt32(p[4].Direction);
        return list;
    }
这是分页代码DAL层的
  public List<SupplierInfo> GetPageSupplier(int pagesize,int index,int id,out int sum,out int counts)
    {
        return server.GetPageSupplier(pagesize, index, id, out sum, out counts);
    }这是BLL层的
public void SearchSupplier()
    {
        string plusid = Request["PlusId"];
        string json;
        int pageIndex = Convert.ToInt32(Request["pageIndex"]);
        int pageSize = Convert.ToInt32(Request["pageSize"]);
        int i; int j;
        json = new JavaScriptSerializer().Serialize(supplinfo.GetPageSupplier(pageSize,pageIndex,Convert.ToInt32(plusid),out i,out j));
        i=0;j=0;
        //json = new JavaScriptSerializer().Serialize(supplinfo.GetSupplierBuPlusId(Convert.ToInt32(plusid)));
        Response.Write(json);
    }
这是ui层的
grid.load({ PlusId: e.node.id});这是前台

Rank: 8Rank: 8

地板
发表于 2014-2-17 16:10:38 |只看该作者
dianaly122 发表于 2014-2-17 16:01
create  proc [dbo].
@pagecount int,@index int,@id int,@type varchar(10),@sumcount int output,@cou ...

表格内部是ajax的交互, 我们内部默认会把当前分页的pageIndex和pageSize放到ajax的data里面传到后台

后台request pageIndex即可.

grid.load({key:value})也是,内部会把你的{key:value}当成data,发往后台,后台request  key.
你用你那的环境,测试我们demo,是否正常

Archiver|普加软件

GMT+8, 2024-5-30 12:57 , Processed in 1.022228 second(s), 9 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部