解决Ext从webservice中取数据的分页问题

service中的代码

[WebMethod]
public IPNodeCurrent QueryAllIPNode(int start, int limit)
{

DataTable dtone = (new IPNodeDA()).getAllIPNodes();
List<IPNode> nodeList = new List<IPNode>();

for (int nodeLen = 0; nodeLen<dtone.Rows.Count; nodeLen++)
{
IPNode node = new IPNode();
node.IPNodeID = int.Parse(dtone.Rows[nodeLen][0].ToString());
node.IPNodeName = string.Format("{0}", dtone.Rows[nodeLen][1]);
node.Desc = string.Format("{0}", dtone.Rows[nodeLen][2]);

node.Start = string.Empty;
node.Stop = string.Empty;
node.Del = string.Empty;

nodeList.Add(node);
}



List<IPNode> currentPageList = new List<IPNode>();

if ((start + limit) > nodeList.Count)
{
for (int count = start; count < nodeList.Count; count++)
{
currentPageList.Add(nodeList[count]);
}

}
else
{
for (int count = start; count < (start+limit); count++)
{
currentPageList.Add(nodeList[count]);
}

}
//for (int count = start; count <nodeList.Count; count++)
//{
// currentPageList.Add(nodeList[count]);
//}

IPNodeCurrent inc = new IPNodeCurrent();
inc.Current = currentPageList.ToArray();
inc.TotalCount = nodeList.Count;

return inc;
}

在ext页面端传入两参数
store.load({params:{start:0, limit:4}});


即可实现分页
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值