我有一个SharePoint列表,我需要逐页显示数据。必须要求能够跳转页面并显示总页数(即1,2,3…)15)。SharePoint允许这样做吗?
到目前为止,我试过:CAML:似乎是不可能的,因为CAML查询需要前一页的元素来显示下一页。
REST: using/_vti_bin/listdata。svc和LINQ查询:
//VS2010 creates classes for all list items when adding reference to listdata.svc
RootDataContext context = new RootDataContext(new Uri(Utils.ListServiceUrl));
context.Credentials = System.Net.CredentialCache.DefaultCredentials;
//this works like a charm, I am able to filter items by category and page them
//(category is a single lookup)
var query = (DataServiceQuery<NewsItemsItem>)context.NewsItems.
Where(i => i.CategoryId == 2).
Skip(3).
Take(2);
//however, if I need more advanced filtering (Tags is multilookup) I fail
//(the code below won't work as this approach does not allow to make aggregation
//queries inside other query)
var query = (DataServiceQuery<NewsItemsItem>)context.NewsItems.
Where(i => i.Tags.Where(t => t.Id == 3).Count() > 0).
Skip(3).
Take(2);
如果您能给我一些建议,我将不胜感激。
http://msdn.microsoft.com/en-us/library/ff798478.aspx跳过与linq sharepoint不能帮助你。因为sharepoint没有"跳过N个值"的工具。
查看这篇文章。如果您要按列排序,并希望在caml中使用此顺序对该列表进行分页,那么它们将非常有用。
http://blogs.msdn.com/b/dbadki/archive/2008/10/08/caml-query-execution-using-pagination-for-custom-columns.aspx http://blogs.msdn.com/b/colbyafrica/archive/2009/02/19/learning-sharepoint-part-vi-list-pagination.aspx 无论如何,sharepoint中的列表分页是非常可怕的(我认为不仅仅是对我来说)。因为我只能像"上一个-下一个"分页,而不是"1 2 3 4 5 ....