SP.ListItemCollectionPosition object
Specifies the information required to get the next page of data for a list view.
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.ListItemCollectionPosition()
Members
The ListItemCollectionPosition object has the following members.
Constructor
The ListItemCollectionPosition object has the following constructor.
Constructor |
Description |
---|---|
Initializes a new instance of the SP.ListItemCollectionPosition object. |
Methods
The ListItemCollectionPosition object has the following methods.
Method |
Description |
---|---|
Properties
The ListItemCollectionPosition object has the following properties.
Property |
Description |
---|---|
Gets or sets a value that specifies information, as name-value pairs, required to get the next page of data for a list view. |
|
This member is reserved for internal use and is not intended to be used directly from your code. |
Example
The following example creates an input button on an application page that displays titles from the list of announcements on the current web site two at a time.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">
var listItems; // The list of retrieved items.
var query; // For paging, reuse the same query object.
var targetList; // The list from which to retrieve items.
var clientContext;
function runCode() {
clientContext = new SP.ClientContext();
targetList = clientContext.get_web().get_lists().getByTitle('Announcements');
query = new SP.CamlQuery();
query.set_viewXml("<View><ViewFields><FieldRef Name='Title'/></ViewFields><RowLimit>2</RowLimit></View>");
listItems = targetList.getItems(query);
clientContext.load(listItems);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
var message = "Titles, two at a time:\n";
var listEnumerator = listItems.getEnumerator();
while (listEnumerator.moveNext()) {
message += "\nTitle=" + listEnumerator.get_current().get_item("Title")
}
alert(message);
var position = listItems.get_listItemCollectionPosition();
if (position != null) {
query.set_listItemCollectionPosition(position);
listItems = targetList.getItems(query);
clientContext.load(listItems);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onQueryFailed(sender, args) {
alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
}
</script>
<input id="Button1" type="button" value="Run Code" onclick="runCode()" />
</asp:Content>