Location="CommandUI.Ribbon.ListView">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
Now, I want to add a button to a normal custom list where there is a tab called Items (not Documents). How can I do that? Changing Ribbon.Documents... to Ribbon.Items... doesn't work.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="RibbonAlert"
RegistrationId="101"
RegistrationType="List"
Location="CommandUI.Ribbon.ListView">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListItem.Manage.Controls._children">
<Button Id="SampleRibbonCommand"
Alt="Shows an alert."
Description="Shows an alert, just to make an example."
Sequence="5"
Command="ShowSampleAlert"
Image16by16="/_layouts/images/DeviantPoint.DownloadZip/zip_16x16.png"
Image32by32="/_layouts/images/DeviantPoint.DownloadZip/zip_32x32.png"
LabelText="Ribbon Like"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="ShowSampleAlert"
EnabledScript="javascript:
function checkDocsSelected()
{
// Check the number of selected items
var items = SP.ListOperation.Selection.getSelectedItems();
return (items.length >= 1);
}
checkDocsSelected();"
CommandAction="javascript:
// Shared variables
var ctx;
var itemsToLike;
var notifyId = '';
// Function that archives the selected items
function likeDocs() {
// Notify the end user about the work in progress
this.notifyId = SP.UI.Notify.addNotification('Liking docs...', true);
// Get the current ClientContext
this.ctx = new SP.ClientContext.get_current();
// Get the current Web
var web = this.ctx.get_web();
// Get the currently selected list
var listId = SP.ListOperation.Selection.getSelectedList();
var sourceList = web.get_lists().getById(listId);
// Get the selected items and like each of them
var items = SP.ListOperation.Selection.getSelectedItems(this.ctx);
var item;
this.itemsToLike = new Array(items.length);
for(var i in items) {
item = items[i];
// Get each selected item
var listItem = sourceList.getItemById(item.id);
this.itemsToLike.push(listItem);
this.ctx.load(listItem);
}
// Effectively load items from SharePoint
this.ctx.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));
}
// Delegate called when server operation is completed upon success
function onQuerySucceeded(sender, args) {
// Mark each item as Like
var item = null;
do {
item = this.itemsToLike.pop();
if (item != null) {
alert(item.get_item('Title'));
item.set_item('Title', 'Like');
item.update();
}
} while (item != null);
// Effectively update items in SharePoint
this.ctx.executeQueryAsync(Function.createDelegate(this, onUpdateSucceeded), Function.createDelegate(this, onQueryFailed));
}
// Delegate called when server operation is completed upon success
function onUpdateSucceeded(sender, args) {
SP.UI.Notify.removeNotification(this.notifyId);
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
// Delegate called when server operation is completed with errors
function onQueryFailed(sender, args) {
alert('The requested operation failed: ' + args.toString());
}
likeDocs();" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
Location="CommandUI.Ribbon.ListView">
toLocation="CommandUI.Ribbon">
in line 7?
Please have a look
http://sharepoint.stackexchange.com/questions/6181/add-button-link-action-to-a-list