我有我需要逐頁顯示的數據的SharePoint列表。必須要求是能夠跳過頁面並顯示總頁數(即1,2,3 ... 15)。 SharePoint允許這樣做嗎?SharePoint 2010中的富表列表分頁
到目前爲止我嘗試過: CAML:似乎不可能,因爲CAML查詢需要前一頁中的元素來顯示下一個元素。
REST:使用/_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);
我將不勝感激,如果你能給我什麼建議。
決定擺脫我的列表中的多查找列,並把一個簡單的字符串列,而不是(即#1#4 #6)。現在我可以在這裏使用REST方法。 – DizzyBlack