Disable button from page layout used in VF page
you have used a standard page layout in vf page and you do not want to enable all buttons of that page layout in the VF page always. That means we need to conditionally enable or disable page layout buttons in vf page .
use below tag to display standard layout in VF page
<apex:detail relatedList="false"></apex:detail>
we need to use javascrcipt or jquery to enable or disable the buttons based on some condition dynamically.
in below code snappet, thisLead is a getter to store the current lead record to show lead information in page.
Here I am disabling Convert button for the leads with status "Working Converted". First get the button with getElementByName and set the CSS attribute for the button as Oppacity = 0.65 and cursor as not-allowed.
if ("{!thisLead.Status}" == 'Working - Contacted') { var btns = document.getElementsByName('convert'); for (var i = 0; i < btns.length; i++) { btns[i].style.opacity = 0.65; btns[i].style.cursor = 'not-allowed'; } }