因此,我按照本指南为文档库启用了 Sharepoint 2010 中的评级:http://weblogs.asp.net/bsimser/archive/2009/10/19/sharepoint-2010-what-s-new-ratings-spc09。 aspx
现在我需要一种在 Webpart 中以编程方式获取评分的方法。
我想要一种方法来获得如下列表(尽管欢迎任何其他方式):
Item Id/Url | Rating | UserId
谢谢
因此,我按照本指南为文档库启用了 Sharepoint 2010 中的评级:http://weblogs.asp.net/bsimser/archive/2009/10/19/sharepoint-2010-what-s-new-ratings-spc09。 aspx
现在我需要一种在 Webpart 中以编程方式获取评分的方法。
我想要一种方法来获得如下列表(尽管欢迎任何其他方式):
Item Id/Url | Rating | UserId
谢谢
我在这里找到了答案:http: //msdn.microsoft.com/en-us/library/ff407954.aspx
有趣的是,我在使用 Google 的任何地方都找不到它,我应该搜索“Sharepoint Social Rating”,而不仅仅是“rating”。
You can you SPService to Get Rating on Url:
//Get Rating on Url
//libraryUrl is url of your library
$().SPServices({
operation: "GetRatingOnUrl",
url: libraryUrl,
async: false,
completefunc: function (xData, Status) {
if (Status == "success") {
var url = $(xData.responseXML).find("Url").text();
var rating = $(xData.responseXML).find("Rating").text();
var user = $(xData.responseXML).find("Owner").text();
....
}
}
});
When webservice return xml and then you can get some information you need like: Url, Owner, LastModifiedTime, Title and Rating
以下是从列表中获取项目并在 Web 部件中显示它们的方法。它使用一个简单的 Label 控件,但您可以按照自己喜欢的方式对其进行格式化:
Dim SPListVar As SPList 'SharePoint List
Dim SPColl As SPListItemCollection 'Define a list item Collection
Using Site1 As New SPSite(Me.Context.Request.Url.ToString) 'Define the site
Using Web1 As SPWeb = Site1.OpenWeb 'Define the web
SPListVar = Web1.Lists("Tasks") 'Point to the required list
End Using
End Using
SPColl = SPListVar.GetItems() ' Fill the List item collection with the return data
Dim i As Integer
While i < SPColl.Count
LblRes.Text = LblRes.Text + SPColl.Item(i).Item("Title").ToString + "<BR>"
'Read every record and put it in a new line in the Label control
i = i + 1
End While