none
Add button in Ribbon dynamically RRS feed

  • Question

  • How can I add button to an existing tab "Project" in Ribbon?

    I can't  use elements.xml file, because that would show that button on every page and I need it on only ONE page.

    My guess is that I need to build new web part and add it to page, and with javascript insert button to existing tab section (Workflow, for example) ? But how?

    I am trying to do it with this code, but it doesn't work.

    http://msdn.microsoft.com/en-us/library/ff407578.aspx

    I don't need new Contextual tab, only put one button to an existing tab "Project". Can somebody tell me what do I need to change in order to make this work?

    Tuesday, December 4, 2012 5:09 PM

Answers

All replies

  • Try: http://msdn.microsoft.com/en-us/library/ee767705(office.14).aspx

    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    Tuesday, December 4, 2012 8:29 PM
    Moderator
  • Hi,

    The Project Server ribbon is fully extensible and yes you can use an elements.xml file to do so, the secret is in making sure you target the correct ribbon and group where you want to create your button. 

    I wrote a couple of blog posts on customising the ribbon at http://epmsource.com, specifically this one might help http://epmsource.com/2012/01/26/adding-print-capabilities-to-project-detail-pages/

    What are you trying to add and where?


    Alex Burton
    www.epmsource.com | Twitter
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page

    Wednesday, December 5, 2012 12:20 AM
    Moderator
  • Hi,

    The Project Server ribbon is fully extensible and yes you can use an elements.xml file to do so, the secret is in making sure you target the correct ribbon and group where you want to create your button. 

    I wrote a couple of blog posts on customising the ribbon at http://epmsource.com, specifically this one might help http://epmsource.com/2012/01/26/adding-print-capabilities-to-project-detail-pages/

    What are you trying to add and where?


    But, if I use elements.xml that button will appear on every page on the site. I need button in a ribbon on a single page - just one aspx. And this can be achieved only with web part using javascript like in the link in the first post. But, it doesn't work...  :(
    Wednesday, December 5, 2012 1:15 AM
  • Wednesday, December 5, 2012 1:57 AM
    Moderator
  • What page are you looking to add a button to?

    When you open a project, depending in which status project is (I forgot to mention that, status of a project also needs to checked) on ProjectDetails.aspx.
    Wednesday, December 5, 2012 8:15 AM
  • Can I add a fixed button with elements.xml but to set it as hidden or disabled, and then just enable it on one page?
    Wednesday, December 5, 2012 8:19 AM
  • Hi,

    The ribbon infrastructure in 2010 does have a capability built in to allow the buttons to be turned on or off depending on business logic. In that blog post I pointed you at there was an EnabledScript option in the definition that allows you to determine whether the button in enabled or disabled depending on business rules. In fact that particular example includes logic that turns off the group if the page is called Schedule.aspx, which will achieve something similar to what you want (ProjectDetails.aspx). All you will need to do is add some additional logic to check the stage.

    hope this helps., 


    Alex Burton
    www.epmsource.com | Twitter
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page

    Friday, December 7, 2012 10:15 PM
    Moderator
  • Hi Alex

    I could add a button to the Project detail pages on "Project" and "Page" groups. However I can't add a button on the "Navigate" group. I tried to add a button using existing GroupID = GoToProjectPermissionVisible, but the button is absent.  I could place the button to the end of the group "Navigate" only using the property TemplateAlias="c7" but I could not add the button to any other place within the group. I tried different Sequences and TemplateAlias.

    My code is below. Could you please explain me how I should modify the code to place new button between "Project Site" and "Build Team" buttons?

    I use MS Project Server 2016 on premise 

      <CustomAction Id="Ribbon.Tabs.PDP.Home.GoToProjectPermissionVisible.Controls._children"
                     Location="CommandUI.Ribbon">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
              Location="Ribbon.Tabs.PDP.Home.GoToProjectPermissionVisible.Controls._children">
                        
              <Button Id="Ribbon.Tabs.PDP.Home.GoToProjectPermissionVisible.TasksList"                     
                                      Command="OpenTasksListCmd"
                                      Sequence="15"
                                      Alt="Tasks on Project Site"
                                      Description="Show Project Tasks using SharePoint Tasks List on the project site"
                                      LabelText="Tasks on Project Site"
                                      ToolTipTitle="Show Tasks"
                                      ToolTipDescription="Go to the Project site and display SharePoint Tasks List"
                                          Image32by32="{SiteUrl}/_layouts/15/1033/images/ps32x32.png?rev=40"
                      Image32by32Top="-32"
                      Image32by32Left="0"
                      TemplateAlias="c1"                  />
            </CommandUIDefinition>
    
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
            Command="OpenTasksListCmd"
            EnabledScript="return true;"
             CommandAction="javascript:	OpenTasksList()"/>
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>




    Saturday, May 4, 2019 11:46 AM