能否将 Sharepoint 2010 WebPart 属性 配置为仅特定于用户?

Can a Sharepoint 2010 WebPart property be configured as user-specific only?

背景: 我使用 Visual Studio 和自定义属性开发了几个 SharePoint 2010 web 部件。我还能够使用代码设置这些属性,以便它们持久存在。我还知道 SharePoint 用户可以使用自己的 属性 值等对页面和 Web 部件进行个性化设置。

问题: 是否可以设置一个 属性 始终只针对特定用户?

换句话说,我希望我的 Web 部件有一个 属性,它开始时是空白的,一旦用户在 Web 部件中执行操作就被分配一个值,但该值是特定于该用户的.查看该页面的其他用户需要执行该操作才能获得他们自己的价值。我希望用户无需手动个性化页面即可实现这一点。

我试过设置属性:

Personalizable( PersonalizationScope.User )

后加

WebPartStorage( Storage.Personal )

并做了一些测试,但第一个用户设置的值始终保留到第二个。

我们在个性化方面做的不多,所以我真的很好奇这是否可能。

您应该可以添加属性 [Personalizable(true)]

WebPartStorage 属性(Storage.SharedStorage.Personal)是 SharePoint 2003 的旧 API 的遗留物,如文档所述 here.

在此处查看 Microsoft 的演练文章:Creating a Custom Web Part Editor in SharePoint 2010

The Web Part declares a private variable _tabList as a collection of TabData objects. This collection is wrapped through the TabList property. The property returns an empty collection if _tabList is null. The property is also marked Personalizable, to enable users to customize the tabs.

[...]

// Collection of tabs.
private List<TabData> _tabList;
// Property to hold the collection of tabs.
// Set the Personalizable attribute to true, 
// to allow for personalization of tabs by users.
[Personalizable(true)]
public List<TabData> TabList { 
    get
    {
        if (this._tabList == null)
        {
            // Return an empty collection if null.
            this._tabList = new List<TabData>();
        }
        return this._tabList;
    }            
    set
    {
        this._tabList = value;
    } 
}   

如需更多阅读,请在此处查看 Microsoft 的文档:About Web Part Page personal and shared views

值得注意的是,请考虑以下摘录:

When a Web Part page is in personal page view, you:

  • Can usually view and modify the Layout and Appearance common Web Part properties, but not the Advanced ones. In some cases, the developer of a Web Part may decide not to display some or all common properties or you may not have permission to see them.
  • Can view and modify custom Web Part properties. In some cases, the developer of a Web Part may decide not to display some or all custom properties or you may not have permission to see them.
  • Can view and modify, but not delete, shared Web Parts with appropriate permission. Once you modify a shared Web Part, however, it becomes a personalized Web Part.
  • Can view and modify, but not delete, personalized Web Parts. The modified property values of these Web Parts apply only to you.
  • Can view, modify, and delete private Web Parts. These Web Parts only apply to you, no other users can see them, even in shared view.

默认情况下,在个人视图中编辑页面时,只有 Layout 和 Appearance 属性会为当前用户自定义。自定义属性是共享的,除非您明确将它们个性化。