解决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}});
即可实现分页