我正在尝试为 SharePoint 编写一个 WebPart,它将显示网站最近上传和修改的列表(包括所有文档列表)
为此,我创建了一个 SPGridView,并使用 SPSiteDataQuery 用我的(可自定义的)选定列表填充它。我知道 SPQuery 具有 ListItemCollectionPosition,但据我所知,这不适用于多个列表,并且一次做一个会破坏排序/分页。
这是我所拥有的一个片段:
Dim query As New SPQuery()
Dim lists As String = "<Lists ServerTemplate='101'>"
For Each li As Guid In SelectedLists ' Personalisable Property
lists &= "<List ID='" & li.ToString & "' />"
Next
lists &= "</Lists>"
query.Lists = lists
query.RowLimit = 30 ' This will be the page size and is temporarily hardcoded
' These Id's are all SPBuildInFieldId's converted ToString
query.ViewFields = "<FieldRef ID'" & _filenameId & "' />" &
"<FieldRef ID='" & _modifiedId & "' />" &
"<FieldRef ID='" & _modifiedById & "' />" &
"<FieldRef ID='" & _versionId & "' />" &
"<FieldRef ID='" & _checkedOutToId & "' />" &
"<FieldRef ID='" & _fileSizeId & "' />" &
"<FieldRef ID='" & _createdId & "' />" &
"<FieldRef ID='" & _createdById & "' />"
query.Webs = "<Webs Scope='Recursive' />"
query.Query = "<OrderBy><FieldRef ID='" & _modifiedId & "' Ascending='FALSE' /></OrderBy>"
Dim temp as DataTable = objWeb.GetSiteData(query)
For Each row As DataRow In temp.Rows
Dim aRow = dtTable.Rows.Add()
' Get List Information
Dim listId As Guid = New Guid(row.Item("ListId").ToString)
Dim thisList As SPList = objWeb.Lists(listId)
Dim fileName As String = row.Item(_filenameId).ToString
aRow.Item("DocIcon") = "/_layouts/15/images/" & Utilities.SPUtility.MapToIcon(objWeb, fileName, "")
aRow.Item("FileName") = fileName
aRow.Item("FileLink") = objWeb.Url & "/" & thisList.Title & "/" & fileName
aRow.Item("ListName") = thisList.Title
aRow.Item("ListLink") = objWeb.Url & "/" & thisList.Title
aRow.Item("Modified") = row.Item(_modifiedId).ToString
aRow.Item("ModifiedBy") = New SPFieldLookupValue(row.Item(_modifiedById).ToString).LookupValue
aRow.Item("Version") = row.Item(_versionId).ToString
aRow.Item("CheckedOutTo") = New SPFieldLookupValue(row.Item(_checkedOutId).ToString).LookupValue
aRow.Item("FileSize") = row.Item(_fileSizeId).ToString
aRow.Item("Created") = row.Item(_createdId).ToString
aRow.Item("Author") = New SPFieldLookupValue(row.Item(_createdById).ToString).LookupValue
Next
此 DataTable 设置为我的 SPGridView 的源,并且允许分页(我目前正在使用 SPGridViewPager),但它总是会从查询中返回完整的文档集合,一旦有很多文档,这将导致一些开销的文件。
我想要的是能够在查询本身中分页,以便它只返回当前页面的正确文档(一次约 30 个),但我正在尝试实现这一目标。
是否有我缺少的解决方案可以让我以修改后的顺序查询一组预定的列表,并在查询时分页?
提前感谢并为任何错误的措辞/格式道歉,这是我在这个网站上的第一个问题。