首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-10-28 
解决Ext从webservice中取数据的分页问题service中的代码[WebMethod]public IPNodeCurrent QueryAllIPNode(

解决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}});


即可实现分页

热点排行