Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"List Tools" tab is no longer available after adding webpart to the page

in SharePoint 2010 I have added my webpart above list (standard list or documents library list - it doesn't matter). After this "List Tools" tab is not visible. After some digging I have found, that problem exists even if I add one of the standard SharePoint WebParts.

Here is the same problem and description how to reproduce it: http://www.endusersharepoint.com/STP/viewtopic.php?f=10&t=2027

Has anybody found the solution or real workaround for this?

//EDIT: I've found a "solution". Ribbon is connected with "actual" webpart. One click on the list (to set the focus on it) and the tab is visible again :D

like image 669
Marcin Robaszyński Avatar asked Jan 31 '11 08:01

Marcin Robaszyński


2 Answers

When you add a web part to the standard list views, the page is no longer classified as a list view page, but instead it is classed as an application page.

This means you lose the ribbon menu, as well as the view selector in the breadcrumb.

UPDATE

You can see the code that hides the view selector in:

Microsoft.SharePoint.WebControls.ListTitleViewSelectorMenu.SingleWebPartPresentOnPage

But I can't seem to find the code that hides the ribbon.

UPDATE

Okay i think this will work, add a content editor web part with this code:

<script>
setTimeout(function() {
    var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
    if(elem != null) {
        var dummyevent = new Array();
        dummyevent["target"] = elem;
        dummyevent["srcElement"] = elem;
        WpClick(dummyevent);
    }
}, 2000);
</script>

Replace the MSOZoneCell_WebPartWPQ2 id with the web part zone cell of the list view web part.

like image 55
djeeg Avatar answered Nov 13 '22 09:11

djeeg


This worked for me, but it starts with the documents tab selected, and I preferred to have the default browse tab selected to begin with, so I just added a simple line to the code, do reselect the default tab:

        <script>
        setTimeout(function() {
        var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
           if(elem != null) {
                var dummyevent = new Array();
                dummyevent["target"] = elem;
                dummyevent["srcElement"] = elem;
                WpClick(dummyevent);
                _ribbonStartInit("Ribbon.Browse", true)
            }
        }, 2000);
        </script> 
like image 23
Katrine B. Avatar answered Nov 13 '22 09:11

Katrine B.