SharePoint - Remove the ribbon tabs from a list item

This post will tell you how to remove the tabs on the ribbon when you look at a list item in classic view


Add this code into the display form in SHarePoint designer

<script type="text/javascript">// 
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab(&quot;Ribbon.Read&quot;, true);
ribbon.removeChild(&apos;Ribbon.ListForm.Display&apos;);
ribbon.removeChild(&apos;Ribbon.ListForm.Edit&apos;);
} catch (e)
{ }
}

SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try
{
var pm = SP.Ribbon.PageManager.get_instance();

pm.add_ribbonInited(function () {
ResetRibbon();
});

var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }

if (!ribbon) {
if (typeof (_ribbonStartInit) == &quot;function&quot;)
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
},
&quot;sp.ribbon.js&quot;);
}catch(e)
{}
// </script>

<script type="text/javascript">
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab(&quot;Ribbon.Read&quot;, true);
ribbon.removeChild(&quot;Ribbon.ListForm.Display&quot;);
ribbon.removeChild(&quot;Ribbon.ListForm.Edit&quot;);
} catch (e)
{ }
}

SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try {
var pm = SP.Ribbon.PageManager.get_instance();

pm.add_ribbonInited(function () {
ResetRibbon();
});

var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }

if (!ribbon) {
if (typeof (_ribbonStartInit) == &quot;function&quot;)
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
} catch (e)
{ }
}, &quot;sp.ribbon.js&quot;);

</script>




If you want to keep the display tab up (for workflow approvals, remove this line:
ribbon.removeChild(&apos;Ribbon.ListForm.Display&apos;);
Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment

0 comments:

Post a Comment