</Elements>
Script on page to enable/disable the custom action
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(SingleEnable, "sp.js");
function SingleEnable(EnableForStatus, PermissionKind) {
var selectedItems = SP.ListOperation.Selection.getSelectedItems();
var ci2 = CountDictionary(selectedItems);
Custom action with multiple tabs and multiple groups with multiple
buttons
: <?xml version="1.0" encoding="utf-8"?>
2:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
3: <CustomAction
4: Id="COB.SharePoint.Ribbon.CustomTab"
5: Location="CommandUI.Ribbon"
6: RegistrationType="List"
7: RegistrationId="101">
8: <CommandUIExtension>
9: <CommandUIDefinitions>
10: <CommandUIDefinition
Location="Ribbon.Tabs._children">
11: <Tab Id="COB.SharePoint.Ribbon.CustomTab"
12: Title="Chris's custom
tab"
13: Description="Groups and
controls will go in here"
14: Sequence="550">
15: <Scaling Id="COB.SharePoint.Ribbon.CustomTab.Scaling">
16: <MaxSize Id="COB.SharePoint.Ribbon.CustomTab.NotificationGroup.MaxSize"
17: GroupId="COB.SharePoint.Ribbon.CustomTab.NotificationGroup"
18: Size="OneLarge"/>
19: <MaxSize Id="COB.SharePoint.Ribbon.CustomTab.StatusGroup.MaxSize"
20: GroupId="COB.SharePoint.Ribbon.CustomTab.StatusGroup"
21: Size="TwoMedium"/>
22: <MaxSize Id="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup.MaxSize"
23: GroupId="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup"
24: Size="TwoLarge"/>
25: <Scale Id="COB.SharePoint.Ribbon.CustomTab.NotificationGroup.Scaling.CustomTabScaling"
26: GroupId="COB.SharePoint.Ribbon.CustomTab.NotificationGroup"
27: Size="OneLarge" />
28: <Scale Id="COB.SharePoint.Ribbon.CustomTab.StatusGroup.Scaling.CustomTabScaling"
29: GroupId="COB.SharePoint.Ribbon.CustomTab.StatusGroup"
30: Size="TwoMedium" />
31: <Scale Id="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup.Scaling.CustomTabScaling"
32: GroupId="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup"
33: Size="TwoLarge" />
34: </Scaling>
35: <Groups Id="COB.SharePoint.Ribbon.CustomTab.Groups">
36: <Group
37: Id="COB.SharePoint.Ribbon.CustomTab.NotificationGroup"
38: Description="Contains
notification items"
39: Title="Notification messages"
40: Sequence="10"
41: Template="Ribbon.Templates.OneLargeExample">
42: <Controls Id="COB.SharePoint.Ribbon.CustomTab.NotificationGroup.Controls">
43: <Button
44: Id="COB.SharePoint.Ribbon.CustomTab.NotificationGroup.Notify"
45: Command="COB.Command.Notify"
46: Sequence="10"
47: Image16by16="/_layouts/images/NoteBoard_16x16.png"
48: Image32by32="/_layouts/images/NoteBoard_32x32.png"
49: Description="Uses the
notification area to display a message."
50: LabelText="Notify hello"
51: TemplateAlias="cust1"/>
52: </Controls>
53: </Group>
54: <Group
55: Id="COB.SharePoint.Ribbon.CustomTab.StatusGroup"
56: Description="Contains 'add
status' items"
57: Title="Add status
messages"
58: Sequence="20"
59: Template="Ribbon.Templates.TwoMediumExample">
60: <Controls Id="COB.SharePoint.Ribbon.CustomTab.StatusGroup.Controls">
61: <Button
62: Id="COB.SharePoint.Ribbon.CustomTab.StatusGroup.AddStatusInfo"
63: Command="COB.Command.AddStatusInfo"
64: Sequence="10"
65: Image16by16="/_layouts/images/info16by16.gif"
66: Image32by32="/_layouts/images/info16by16.gif"
67: Description="Uses the status
bar to display an info message."
68: LabelText="Info status"
69: TemplateAlias="cust2"/>
70: <Button
71: Id="COB.SharePoint.Ribbon.CustomTab.StatusGroup.AddStatusWarning"
72: Command="COB.Command.AddStatusWarn"
73: Sequence="20"
74: Image16by16="/_layouts/images/warning16by16.gif"
75: Image32by32="/_layouts/images/warning32by32.gif"
76: Description="Uses the status
bar to display a warning message."
77: LabelText="Warning
status"
78: TemplateAlias="cust3"/>
79: </Controls>
80: </Group>
81: <Group
82: Id="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup"
83: Description="Contains 'remove
status' items"
84: Title="Remove status
messages"
85: Sequence="30"
86: Template="Ribbon.Templates.TwoLargeExample">
87: <Controls Id="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup.Controls">
88: <Button
89: Id="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup.RemoveLastStatusButton"
90: Command="COB.Command.RemoveLastStatus"
91: Sequence="10"
92: Image16by16="/_layouts/images/warning16by16.gif"
93: Image32by32="/_layouts/images/CRIT_32.GIF"
94: Description="Removes the last
message from the status bar."
95: LabelText="Remove last status
message"
96: TemplateAlias="cust4"/>
97: <Button
98: Id="COB.SharePoint.Ribbon.CustomTab.RemoveStatusGroup.RemoveAllStatusButton"
99: Command="COB.Command.RemoveAllStatus"
100: Sequence="20"
101: Image16by16="/_layouts/images/warning16by16.gif"
102: Image32by32="/_layouts/images/CRIT_32.GIF"
103: Description="Removes all
messages from the status bar."
104: LabelText="Remove all status
messages"
105: TemplateAlias="cust5"/>
106: </Controls>
107: </Group>
108: </Groups>
109: </Tab>
110: </CommandUIDefinition>
111: <CommandUIDefinition
Location="Ribbon.Templates._children">
112: <GroupTemplate Id="Ribbon.Templates.OneLargeExample">
113: <Layout Title="OneLarge"
LayoutTitle="OneLarge">
114: <Section Alignment="Top" Type="OneRow">
115: <Row>
116: <ControlRef DisplayMode="Large" TemplateAlias="cust1" />
117: </Row>
118: </Section>
119: </Layout>
120: </GroupTemplate>
121: </CommandUIDefinition>
122: <CommandUIDefinition
Location="Ribbon.Templates._children">
123: <GroupTemplate Id="Ribbon.Templates.TwoMediumExample">
124: <Layout Title="TwoMedium"
LayoutTitle="TwoMedium">
125: <Section Alignment="Top" Type="TwoRow">
126: <Row>
127: <ControlRef DisplayMode="Medium" TemplateAlias="cust2" />
128: </Row>
129: <Row>
130: <ControlRef DisplayMode="Medium" TemplateAlias="cust3" />
131: </Row>
132: </Section>
133: </Layout>
134: </GroupTemplate>
135: </CommandUIDefinition>
136: <CommandUIDefinition
Location="Ribbon.Templates._children">
137: <GroupTemplate Id="Ribbon.Templates.TwoLargeExample">
138: <Layout Title="TwoLarge"
LayoutTitle="TwoLarge">
139: <Section Alignment="Top" Type="OneRow">
140: <Row>
141: <ControlRef DisplayMode="Large" TemplateAlias="cust4" />
142: <ControlRef DisplayMode="Large" TemplateAlias="cust5" />
143: </Row>
144: </Section>
145: </Layout>
146: </GroupTemplate>
147: </CommandUIDefinition>
148: </CommandUIDefinitions>
149: <CommandUIHandlers>
150: <CommandUIHandler
151: Command="COB.Command.Notify"
152: CommandAction="javascript: var
notificationId = SP.UI.Notify.addNotification('Hello from the notification
area'); " />
153: <CommandUIHandler
154: Command="COB.Command.AddStatusInfo"
155: CommandAction="javascript:
156: var statusId =
SP.UI.Status.addStatus('Quite important status message');
157: visibleStatusIds.push(statusId);
158: enableRemoveStatusButton();
159: RefreshCommandUI();" />
160: <CommandUIHandler
161: Command="COB.Command.AddStatusWarn"
162: CommandAction="javascript:
163: var warnStatusId = SP.UI.Status.addStatus('Very
important status message');
164:
SP.UI.Status.setStatusPriColor(warnStatusId, 'red');
165:
visibleStatusIds.push(warnStatusId);
166: enableRemoveStatusButton();
167: RefreshCommandUI(); " />
168: <CommandUIHandler
169: Command="COB.Command.RemoveLastStatus"
170: EnabledScript="javascript:
enableRemoveStatusButton();"
171: CommandAction="javascript:
172:
SP.UI.Status.removeStatus(visibleStatusIds[visibleStatusIds.length
- 1]);
173: visibleStatusIds.pop();
174: enableRemoveStatusButton();
175: RefreshCommandUI();" />
176: <CommandUIHandler
177: Command="COB.Command.RemoveAllStatus"
178: EnabledScript="javascript:
enableRemoveStatusButton();"
179: CommandAction="javascript:
180: SP.UI.Status.removeAllStatus(true);
181: visibleStatusIds.length = 0;
182: enableRemoveStatusButton();
183: RefreshCommandUI();" />
184: </CommandUIHandlers>
185: </CommandUIExtension>
186: </CustomAction>
187: <CustomAction
188: Id="COB.Command.RemoveLastStatus.CheckEnable" Location="ScriptLink"
189: ScriptBlock="
190: var visibleStatusIds = [];
191: function enableRemoveStatusButton() {
192: return (visibleStatusIds.length > 0);
193: }" />
194:
</Elements>
Referred Areas :
Architecture of ribbon
Modifying Custom Action On Ribbon(Create new tab etc)
How to create custom action
Custom action action id’s
Enable scripts