Archive

Archive for May, 2017

SharePoint 2013: Make list tools appear again when added multiple web parts on allitems.aspx page

Recently while working with one of the requirement, I needed to add a content editor web part on Allitems.aspx page, I completed the requirement with adding the CE web part on the page but later testing team reported that the top level ‘list tools’ section is not appearing.

ListTools1

After some analysis I found the issue is nothing but default behavior, while allitems.aspx page is unmodified SharePoint knows that list tools section should be shown always and for the same list or library, when we add some other web part like content editor web part the SharePoint actually not able to understand where the focus currently on i.e. on Allitems web part or on the new web part we added.

Solution:

If customer is fine we can ask customer to click on the List Views web part, then customer will be able to see the list tools directly.

Other solution is to keep the focus on the List Views web part using JavaScript.

<script type="text/javascript">

ExecuteOrDelayUntilScriptLoaded(init_defaultWP, "sp.ribbon.js");

function init_defaultWP() {

setTimeout(function () {

var defaultWP = document.getElementById("MSOZoneCell_WebPartWPQ2");

WpClick({ target: defaultWP, srcElement: defaultWP });

SP.Ribbon.WebPartComponent.$3.deselectWebPartAndZone = function () { };

}, 100);

}

</script>

Happy learning.

Advertisements