当前位置: 代码迷 >> Web前端 >> 解决Ext从webservice中取数据的分页有关问题
  详细解决方案

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

热度:60   发布时间:2012-10-28 09:54:44.0
解决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}});


即可实现分页
  相关解决方案