"The day you stop learning SharePoint is the day you stop using it."

Showing posts with label Ribbon Customization. Show all posts
Showing posts with label Ribbon Customization. Show all posts

SHAREPOINT 2010 RIBBON CUSTOMIZATION – Add a Print button on document library’s display form ribbon







This was again a custom requirement by one of the client based in Singapore who requested to add a print button in the document library’s display form ribbon to print the display form. And again I developed a custom feature in Visual Studio 2010 starting with an Empty SharePoint Project template.

Here are the steps to start developing the custom feature.

1)    Follow the steps and create an Empty SharePoint Project as given in the article:
http://sharepointdecode.blogspot.in/2012/05/display-warning-message-box-on-click-of.html
2)  While following the steps in above article at step 8) copy and paste the below code.
<CustomAction
   Id="PrintRibbonButton.Action" Location="CommandUI.Ribbon"
   RegistrationType="List" RegistrationId="101">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="PrintList" Command="PrintList" Description="Print List" LabelText="Print"
          Image32by32="~/_layouts/Images/CustomPrintButton/printdoc.png"     TemplateAlias="o1" Sequence="20"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="PrintList" CommandAction="javascript:window.print();" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

3)  Here you have to perform an additional step to add the print button icon. Right click the project and click Add -> SharePoint Mapped Folder and select Template -> IMAGES from the Add SharePoint Mapped Folder.















    You will notice a folder created in your project file. Now add print icon image in the 
created Image folder. If you do not have a 32x32 print icon then you may download it from here: http://www.softicons.com/free-icons/toolbar-icons/32x32-free-design-icons-by-aha-soft/print-icon

In my case I added the print icon under a folder name “CustomPrintButton”, Image32by32="~/_layouts/Images/CustomPrintButton/printdoc.png"
This will automatically add the print icon image to IMAGES folder of 14 hive

Now you are at the final step. Build the solution and deploy.

Please make a note here the solution will be automatically deploy to the site you selected for debugging. To deploy the solution to other web application you should use the SharePoint 2010 Management Shell.

To add and install the custom feature to other web application refer to the Microsoft technet site:

YES ! You have done creating the custom solution. Now after successful deployment of the print custom feature go to your SharePoint Site and under site collection features activate it. 
HAPPY PRINITING……… J
Share:

SHAREPOINT 2010 RIBBON CUSTOMIZATION - Display a warning message box on click of Cancel button of EditForm Ribbon

One of our customer based in Singapore requested to display a warning message on click of Cancel button of an EditForm of SharePoint Foundation 2010 document library. This feature is not available OOB, you need to develop a custom feature through Visual Studio 2010 as I did.

You need to follow the below sequence of steps to achieve the above goal:-
   1)    Go to the server where your SharePoint Server/Foundation is installed.
   2)    Start Visual Studio 2010 and Create an Empty SharePoint Project.
   3)    Select the site for debugging and select “Deploy as a Sanboxed Solution.”

Now your new Empty SharePoint Project is created.
   4)    In the Solution Explorer, right click Feature folder and Select “Add Feature.”









 


5) After adding Feature, add an Empty Element by right clicking the Project and select Add -> New Item.












  

6) Select the Empty Element template and provide an appropriate name to it.



 










7)    
Open the Elements.xml under CustomRibbonElement (Empty Element template). I named the Empty Element as “CustomRibbonElement.”













  


8)   
Now in the opened Elements.xml you need to add xml code to create the custom feature.

And here is the complete code:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <CustomAction
     Id="DisplayDialogBox"
     Location="CommandUI.Ribbon"
     RegistrationId="101"
   RegistrationType="List">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.DocLibListForm.Edit.Commit.Cancel"/>
      </CommandUIDefinitions>
    </CommandUIExtension>
  </CustomAction>
  
  <CustomAction Id="Ribbon.Edit.Cancel.Msgbox"
                  Location="CommandUI.Ribbon" >
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.DocLibListForm.Edit.Commit.Controls._children">
          <Button
                Id="Ribbon.Edit.Cancel.MyButton"
                Sequence="20"
                Command="ConfirmClose"
                Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="0" Image16by16Left="-248"
                Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-448" Image32by32Left="-288"
                LabelText="$Resources:core,cui_ButListFormCancel;"
                ToolTipTitle="$Resources:core,cui_ButListFormCancel;"
                ToolTipDescription="$Resources:core,cui_STT_ButListFormCancel;"
                TemplateAlias="o1"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="ConfirmClose"
                          CommandAction="javascript:if(confirm('Are you sure, you want to Cancel?')){SP.UI.ModalDialog.get_childDialog().close();}"/>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
  
</Elements>



Now you are at the final step. Build the solution and deploy.

Please make a note here the solution will be automatically deploy to the site you selected for debugging. To deploy the solution to any web application you should use the SharePoint 2010 Management Shell.

To add and install the custom feature to any web application refer to the Microsoft technet site:
First add the solution: http://technet.microsoft.com/en-us/library/ff607552.aspxSecond install the solution: http://technet.microsoft.com/en-us/library/ff607534.aspx

Here is the output:
 












Share:

SharePoint-StackExchange Moderator

Author's Profile

My photo
India
A SharePoint Enthusiast working as a Lead Solution Architect for an IT Software & Consulting Company in Mumbai. I believe in giving back to the community through which I also learn and develop and eventually grow as an individual and professional. This blog is a small contribution to the community where I live in and may help someone who is seeking knowledge like me.

Popular Posts

Powered by Blogger.

Contact Form

Name

Email *

Message *

Total Pageviews