5

In SharePoint 2010, if you have more than one web part on a web part page, the ribbon disappears because SharePoint doesn't know which web part to display the ribbon for (this is by design because if you have a document library web part and a list web part on the same page, the ribbons are obviously different for the two and SharePoint needs to know which web part to display the ribbon for).

Once you select a web part (by clicking on it) the selected web part will become "active" and the correct ribbon will show up.

Is there a way to automatically select a list view web part on load? Can this be done via javascript or a querystring SharePoint can understand?

For example, if I have a document library web part and a list view web part on a page, I want the document library web part to be selected by default and the document library ribbon to show when the page is first loaded.

1
  • My issue is also simillar but the actual problem is that in my page i have a couple of webparts and the ribbon is not showing up even afetr selecting item check box, can you please help me in resolving the issue. Thanks Bala
    – user4239
    Jul 26, 2011 at 14:36

1 Answer 1

9

Put this in a content editor webpart

<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>
1
  • 2
    Brilliant, thanks djeeg! I changed the code to this so there isnt a 2 second delay. <script> $(document).ready( function() { var elem = document.getElementById("MSOZoneCell_WebPartWPQ2"); if(elem != null) { var dummyevent = new Array() dummyevent["target"] = elem dummyevent["srcElement"] = elem WpClick(dummyevent) } } ) </script>
    – user9254
    Jul 3, 2012 at 6:08

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.