Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to add buttons to ribbon for a normal list

Posted on 2013-01-08
9
Medium Priority
?
869 Views
Last Modified: 2013-01-09
I have added a custom button to the ribbon in a document library in Sharepoint 2010, using the following lines in elements.xml:
Location="CommandUI.Ribbon.ListView">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">

Open in new window

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.
0
Comment
Question by:kasperEH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 13

Expert Comment

by:Yagya Shree
ID: 38754224
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38754376
Hi,
try
"Ribbon.ListItem.Manage"

A complete overview of standard elements:
http://msdn.microsoft.com/en-us/library/ee537543%28office.14%29.aspx

And one of the best resources on the web in regards to ribbon/customizations:
Chris O`Brian
http://www.sharepointnutsandbolts.com/2010/01/adding-ribbon-items-into-existing.html

HTH
Rainer
0
 

Author Comment

by:kasperEH
ID: 38754498
Hi,

I have tried both "Ribbon.ListItem.Manage" and "Ribbon.ListItem.Manage.Controls._children", but it doesn't seem to work. Even though it looks like it should be here based on the articles you link to. There must be some detail I have overlooked. Any ideas?

Kind regards,
Kasper
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38754718
Hi Kasper,

could you perhaps attach the whole elements.xml?
Thanks

KR
Rainer
0
 

Author Comment

by:kasperEH
ID: 38754728
Here it is:
<?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>

Open in new window

0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38754856
Hi,
just a quick first shot:
Can you change
Location="CommandUI.Ribbon.ListView">

Open in new window

to
Location="CommandUI.Ribbon">

Open in new window

in line 7?

HTH
Rainer
0
 

Author Comment

by:kasperEH
ID: 38754906
I have changed line 7 and I still can't see the button. I would like to have it here:
Screenshot of ribbonIn either the Manage or Actions section.
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 38755476
Hi,
it is sooo simple:
List has registrationId 100 (doc libs do have 101).
Therefore just change the RegistrationId to 100 and voila - you should see your action.

HTH
Rainer
0
 

Author Closing Comment

by:kasperEH
ID: 38758007
Thank you very much for your help, Rainer. I finally made it work.
In addition to your line change:

 RegistrationId="100"

- I found out that I could use the following in the location line:
 <CommandUIDefinition Location="Ribbon.ListItem.Actions.Controls._children">

I couldn't get "Ribbon.ListItem.Manage" or "Ribbon.ListItem.Manage.Controls._children" to work.

Best regards,
Kasper
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question