SharePoint 2010 Hide Ribbon using JQuery in "EnabledScript"

Problem Understanding: In SharePoint ribbon control there is “EnabledScript” parameter that used to enable and disable the icon from the ribbon based on the condition logic in your method. So the requirement is to hide the button from the ribbon instead of disabled it.

Requirement: Hide the button from the ribbon instead of disables it.

Solution: In SharePoint ribbon control there is “EnabledScript” parameter that used to enable and disable the icon. So in this function I decided to hide the ribbon control using JQuery. Here comes the problem the ID of the icon is   DATA.SharePoint.Ribbon.NewControlInExistingGroup.NotifyLarge” and it contains the “.” So to escape the “.” We required to add the “\\” in front of “.”.

Implementation: So the following Script that I used to hide the ribbon icon. In this code I checked the controlexistId control existence and based on the logic I hide the icon.

EnabledScript = "javascript:EnableDisable() function EnableDisable() { var result = false; if($('tr[id$=controlexistId]').length>0) { result=true; } if(!result) { $('a[id=DATA\\.SharePoint\\.Ribbon\\.NewControlInExistingGroup\\.NotifyLarge]').css('display','none'); } return result;}" / >

Popular posts from this blog

SharePoint RPC Protocols Examples Using OWSSVR.DLL

SharePoint 2016 JavaScript framework

STS CryptographicException Error : Key set does not exist