在做知识库文档管理模块中,有一个需求,就是想要在自定义列表当中,增加一个,我的收藏功能。按照sharepoint默认的列表来做,我们可以在列表的标题字段中,增加一个功能菜单项,叫我的收藏.如下图。
点击收藏,弹出一个提示框,点击确定,我们把这个纪录添加到收藏记录表。
还是沿用前面的一个sharepoint project ,sharepoint 2010 如何扩展webpart自定义属性边栏字段 custom webpart properties ,在其基础上,来做这个功能。
1。添加一个空元素,CollectionMenuItem。在这个空元素里面,添加一个CustomAction属性
<CustomAction
Id="CollectionMenuItem"
RegistrationType="List"
RegistrationId="100"
Location="EditControlBlock"
Sequence="301"
Title="我的收藏"
ImageUrl="/_layouts/images/ReportServer/editreport.gif">
<UrlAction Url="javascript:if(confirm('确认要收藏吗?')==false){ return false;}
else{window.location.href='/_layouts/WebpartBarTest/CollectionEdit.aspx?scope=item&ListId={ListId}&Itemid={ItemId}&CollectionType=CustomList'}"/>
</CustomAction>
2。部署下project,我们会看到,所有的sharepoint custom list,都会有“我的收藏”这个菜单项。点击我的收藏,会提交一条数据到收藏记录表。
Sl .No
|
Name
|
Registration ID
|
1
|
NoListTemplate
|
0
|
2
|
GenericList
|
100
|
3
|
DocumentLibrary
|
101
|
4
|
Survey
|
102
|
5
|
Links
|
103
|
6
|
Announcements
|
104
|
7
|
Contacts
|
105
|
8
|
Events
|
106
|
9
|
Tasks
|
107
|
10
|
DiscussionBoard
|
108
|
11
|
PictureLibrary
|
109
|
12
|
DataSources
|
110
|
13
|
WebTemplateCatalog
|
111
|
14
|
UserInformation
|
112
|
15
|
WebPartCatalog
|
113
|
16
|
ListTemplateCatalog
|
114
|
17
|
XMLForm
|
115
|
18
|
MasterPageCatalog
|
116
|
19
|
NoCodeWorkflows
|
117
|
20
|
WorkflowProcess
|
118
|
21
|
WebPageLibrary
|
119
|
22
|
CustomGrid
|
120
|
23
|
SolutionCatalog
|
121
|
24
|
NoCodePublic
|
122
|
25
|
ThemeCatalog
|
123
|
26
|
DataConnectionLibrary
|
130
|
27
|
WorkflowHistory
|
140
|
28
|
GanttTasks
|
150
|
29
|
Meetings
|
200
|
30
|
Agenda
|
201
|
31
|
MeetingUser
|
202
|
32
|
Decision
|
204
|
33
|
MeetingObjective
|
207
|
34
|
TextBox
|
210
|
35
|
ThingsToBring
|
211
|
36
|
HomePageLibrary
|
212
|
37
|
Posts
|
301
|
38
|
Comments
|
302
|
39
|
Categories
|
303
|
40
|
Facility
|
402
|
41
|
Whereabouts
|
403
|
42
|
CallTrack
|
404
|
43
|
Circulation
|
405
|
44
|
Timecard
|
420
|
45
|
Holidays
|
421
|
46
|
IMEDic
|
499
|
47
|
ExternalList
|
600
|
48
|
IssueTracking
|
1100
|
49
|
AdminTasks
|
1200
|
50
|
HealthRules
|
1220
|
51
|
HealthReports
|
1221
|
52
|
InvalidType
|
-1
|
1
|
NoListTemplate
|
0
|
Attribute |
Description |
---|---|
Command |
Required. The name of a command. The value of this attribute matches the value of aCommand attribute on an element that defines a control. |
CommandAction |
Required. A script statement to execute when this handler is invoked. Microsoft SharePoint Foundation calls theeval method, passing in the value of this attribute. The value of the attribute can contain substitution tokens that are transformed at rendering. The following tokens are recognized:
|
EnabledScript |
Optional. A script statement that is executed to determine whether the command is enabled or disabled. The script expression should return aBoolean value,true if the command is enabled andfalse if not. If the ribbon is disabled, commands are grayed out and are not clickable. As with the CommandAction attribute, theeval method is called with the value of this attribute as an argument. TheEnabledScript attribute does not support the substitution tokens that are described for theCommandAction attribute. |
广州京微信息科技有限公司,.微软sharepoint解决方案提供商。