3

I have created a simple Ribbon command that hides the header, footer, and ribbon via jQuery. It then calls window.print() and unhides the previously hidden divs. It works great on my development machine using IE9, and works everywhere using Chrome or Firefox. Unfortunately it does not work in IE8 in production. I tried reverting to IE8 to test but was unable to.

Can you think of anything that could cause my ribbon to be greyed out? My simple code can be found below:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
  Id="SharePoint.Ribbon.NewGroupInExistingTab"
  Location="CommandUI.Ribbon">
<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.Templates._children">
      <GroupTemplate Id="Ribbon.Templates.NewGroupInExistingTab.OneLargeExample">
        <Layout Title="NewGroupInExistingTabOneLarge" LayoutTitle="NewGroupInExistingTabOneLarge">
          <Section Alignment="Top" Type="OneRow">
            <Row>
              <ControlRef DisplayMode="Large" TemplateAlias="Button1" />
            </Row>
          </Section>
        </Layout>
      </GroupTemplate>
    </CommandUIDefinition>
    <CommandUIDefinition Location="Ribbon.WikiPageTab.Scaling._children">
      <MaxSize
        Id="SharePoint.Ribbon.NewGroupInExistingTab.NotificationGroup.MaxSize"
        Sequence="15"
        GroupId="SharePoint.Ribbon.NewGroupInExistingTab.NotificationGroup"
        Size="NewGroupInExistingTabOneLarge" />
    </CommandUIDefinition>
    <CommandUIDefinition Location="Ribbon.WikiPageTab.Groups._children">
      <Group
        Id="SharePoint.Ribbon.NewGroupInExistingTab.NotificationGroup"
        Sequence="15"
        Description="Print Page"
        Title="Print"
        Template="Ribbon.Templates.NewGroupInExistingTab.OneLargeExample">
        <Controls Id="SharePoint.Ribbon.NewGroupInExistingTab.NotificationGroup.Controls">
          <Button
            Id="SharePoint.Ribbon.NewGroupInExistingTab.NotificationGroup.Print"
            Command="NewGroupInExistingTab.Command.Print"
            Sequence="10"
            Image16by16="/_layouts/Redacted/Images/Print16.png"
            Image32by32="_layouts/Redacted/Images/Print32.png"
            Description="Print the current page."
            LabelText="Print the current page"
            TemplateAlias="Button1" />
        </Controls>
      </Group>
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler
      Command="NewGroupInExistingTab.Command.Print"
      CommandAction="javascript: 
      $('div#s4-ribbonrow').hide();
      $('div#Redacted-header').hide();
      $('div#Redacted-footer').hide();
      $('div#grid-gutter').css('margin','0');
      $('div#Redacted-wrapper').css('margin','0');
      window.print();
      $('div#s4-ribbonrow').show();
      $('div#Redacted-header').show();
      $('div#Redacted-footer').show();
      $('div#grid-gutter').css('margin','0 auto');
      $('div#Redacted-wrapper').css('margin','0 auto');
      "/>
  </CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
5
  • Are there any errors in the console in the Developer Tools? Jul 13, 2012 at 16:44
  • No errors in the Developer Tools. Jul 13, 2012 at 17:52
  • Maybe try to replacing all the $ with jQuery or try adding EnabledScript="javascript:return true;" Jul 13, 2012 at 18:28
  • I tried your solution but everything works fine in IE9 and IE8. However in IE9 the ribbon flashes before the print dialog shows and in IE8 the ribbon is hidden when the print dialog shows up.
    – Remko
    Sep 12, 2012 at 12:29
  • Once I cleared the cache, it seemed to work fine for me. Sep 13, 2012 at 13:36

1 Answer 1

1

ISS reset and clean browser cache (Dev Tools), could work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.