Query options usage (3): Paging

Source: Internet
Author: User

Use query options to paging inLists. getlistitemsThe method has already been introduced, but the following is not an example. So here is an example for use.

Paging

A string that contains data needed to support paging, includingListitemcollectionpositionnextAttribute. if left empty, the list items returned start from the beginning of the list. client Applications shocould supply the value of a server-supplied bookmark. the server returns the next page of data based on the bookmark supplied. this element is optional, and its default value is an empty string.

 

Next, go to the previous article:Query options usage (2): including the attachment pathTo add some test data.


Note that pagination must be used with rowlimit. First, set rowlimit.


Static
VoidMain (String[] ARGs)

{

 


ListsClient =New
Lists();

Client. url = weburl +"/_ Vti_bin/lists. asmx";

Client. Credentials = system. net.Credentialcache. Defaultcredentials;


XmlnodeResultnode = client. getlistitems (listname,String. Empty, queryall, viewfields,"5", Queryoptions,String. Empty );


Console. Readline ();

}

The following result is displayed:

<RS: Data itemcount = "5"Listitemcollectionpositionnext = "paged = true & amp; p_id = 5"Xmlns: rs = "urn: Schemas-Microsoft-com: rowset">

<Z: Row ows_title = "test01" ows_attachments = "1" ows_author = "1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_editor =" 1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_metainfo =" 1; # "ows _ moderationstatus =" 0 "ows _ Level =" 1 "ows_id =" 1 "ows_uniqueid =" 1; # {E1F2046C-16AC-4650-8EE3-73E12ED5E833} "ows_owshiddenversion =" 2 "ows_fsobjtype =" 1; #0 "ows_created =" 01:37:17 "ows_permmask =" required "ows_modified =" 02:43:10 "ows_fileref =" 1; # teams/smetechcom/lists/queryoptionsdemo/maid "xmlns: z =" # rowsetschema "/>

<Z: Row ows_title = "test05" ows_attachments = "0" ows_author = "1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_editor =" 1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_metainfo =" 5; # "ows _ moderationstatus =" 0 "ows _ Level =" 1 "ows_id =" 5 "ows_uniqueid =" 5; # {authorization} "ows_owshiddenversion =" 1 "ows_fsobjtype =" 5; #0 "ows_created =" 00:46:05 "ows_permmask =" Authorization "ows_modified =" 2012-12-03 00:46:05 "ows_fileref =" 5; # teams/smetechcom/lists/queryoptionsdemo/5_.000 "xmlns: z =" # rowsetschema "/>

</RS: DATA>

The returned XML contains only five data records. The preceding rowlimit settings are the same. Different from the previous examplesListitemcollectionpositionnext = "paged = true & amp;P_id = 5"(The last Id = 5 indicates that the ID of the last record is 5)

Here, many attributes are the parameters that need to be passed in to retrieve the data on the next page. As follows:


Static
XmlnodeQueryoptions

{


Get

{


XmlelementQueryoptions = _ camldoc. createelement ("Queryoptions");

Queryoptions. innerxml ="<Paging listitemcollectionpositionnext = \ "paged = true & amp; p_id = 5 \"/>";


ReturnQueryoptions;

}

}

 

ExampleProgramThe result is the data on the second page.

<RS: Data itemcount = "2" xmlns: rs = "urn: Schemas-Microsoft-com: rowset">

<Z: Row ows_title = "test07" ows_attachments = "0" ows_author = "1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_editor =" 1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_metainfo =" 7; # "ows _ moderationstatus =" 0 "ows _ Level =" 1 "ows_id =" 7 "ows_uniqueid =" 7; # {authorization} "ows_owshiddenversion =" 1 "ows_fsobjtype =" 7; #0 "ows_created =" 00:46:06 "ows_permmask =" Authorization "ows_modified =" 2012-12-03 00:46:06 "ows_fileref =" 7; # teams/smetechcom/lists/queryoptionsdemo/7_.000 "xmlns: z =" # rowsetschema "/>

</RS: DATA>

Because there are less than two pages of data here, the second page is the last page and will not be seenListitemcollectionpositionnext. Using this feature, you can determine whether the current page is the last page.

 

Note the following when using pagination: The SharePoint pagination has an ID passed in. In most cases, IDs are not consecutive (because some records may be deleted ), it will lead to no way to jump to a page accurately.

When Will paging be used?

I have met two scenarios:

    • When processing a large amount of data through the Web Service cache, once the network is unstable, there will be a timeout exception. In this way, you need to use paging, each time a part is returned, and finally a complete data is assembled.
      • The definition of a large amount of data is determined by testing. In the Intranet environment, there are more than user information tables in my experience data. A list with more than 150 columns contains more than 8000 data records.
      • The page size must be balanced. Note that each paging data may fail to be obtained. excessive paging increases the probability. Determine the page size based on your needs.
    • You are more concerned about efficiency. You can use some asynchronous technologies to fill data. For example, in the popular Weibo display style, users do not need to jump to a page.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.