locked
Selecting Sharepoint Document Tab in ribbon in a webpart page RRS feed

  • Question

  • In my intranet site I have a webpart page with Document Library webpart on it. The customer's requirement is that when ever I navigate to this page Document tab in the ribbon should be selected by default.

    I have added the '?InitialTabId=Ribbon.Document' query string of the page's URL but the problem is that now when user browse to the page initialy the 'document' tab is selected for a small fraction of time but on completion of page load the focus is transfered back to 'Browse' tab and 'document' tab disapppears completely.

    can anyone give me solution of the problem any javascript solution will also be fine.

    Saturday, June 30, 2012 3:35 PM

Answers

  • I have found a solution for showing ribbon for a webpart on a webpart page by using following javascript

    function ShowRbbon(wpid)
    {
    var elem = document.getElementById(wpid);     
    if(elem != null) 
    {         
    var dummyevent = new Array();         
    dummyevent["target"] = elem;         
    dummyevent["srcElement"] = elem;         
    WpClick(dummyevent);     
    } 
    }
    

    and then callling the function using content editor webpart on the page

    <script>
    setTimeout(function(){ShowRbbon("WebPartWPQ4")}, 200); </script> 
    Where 'WebPartWPQ4' is the ID of the Document Library webpart. 
    • Proposed as answer by Nazish Ali Rizvi Tuesday, July 10, 2012 8:51 AM
    • Marked as answer by Samim Khan Tuesday, July 10, 2012 9:02 AM
    Tuesday, July 10, 2012 8:47 AM

All replies

  • Hi Samim,

    In my case InitialTabId querry string ?InitialTabId=Ribbon.Document worked for the Documents tab. Here are the some Urls to explain this issue.

    http://littletalk.wordpress.com/2011/09/29/set-the-ribbon-initial-tab-in-sharepoint-2010/

    http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/d884bff7-78bc-4fd0-a183-7f06da001a61/

    Regards


    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful. It'll help other users who are visiting your thread for the similar problem.

    Saturday, June 30, 2012 4:14 PM
  • Thanks Arun,

    I have checked both above links but they are for AllItem.aspx of a document library and I have tested it thats working for me as well incase if I add '?InitialTabId=Ribbon.Document' to the URL of allitem.aspx of document library.

    but my problem is that my document library webpart is on a custom page and what I am trying to do is e-g. '/IT/Pages/ITDocuments.aspx?InitialTabId=Ribbon.Document'.

    Saturday, June 30, 2012 4:52 PM
  • I have found a solution for showing ribbon for a webpart on a webpart page by using following javascript

    function ShowRbbon(wpid)
    {
    var elem = document.getElementById(wpid);     
    if(elem != null) 
    {         
    var dummyevent = new Array();         
    dummyevent["target"] = elem;         
    dummyevent["srcElement"] = elem;         
    WpClick(dummyevent);     
    } 
    }
    

    and then callling the function using content editor webpart on the page

    <script>
    setTimeout(function(){ShowRbbon("WebPartWPQ4")}, 200); </script> 
    Where 'WebPartWPQ4' is the ID of the Document Library webpart. 
    • Proposed as answer by Nazish Ali Rizvi Tuesday, July 10, 2012 8:51 AM
    • Marked as answer by Samim Khan Tuesday, July 10, 2012 9:02 AM
    Tuesday, July 10, 2012 8:47 AM