Hiding Edit Links for Related Lists/Views on a VisualForce Page
mgsmith | Wednesday, June 16th, 2010 | 5 Comments »I had a situation the other day where I needed to hide the Edit & Del links that appear on both the ListView and Related Lists. Luckily in both cases the pages were VisualForce pages, but I did not want to manually recreate the ListViews or Related Lists by hand.
My solution was to use jQuery to quickly select and hide all elements that had a class of “actionLink”:
<apex:page tabStyle="Workshops__tab">
<apex:includeScript value="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"/>
<apex:sectionHeader title="Data Entry Portal" subTitle="Workshops" />
<apex:pageMessages />
<apex:ListViews type="Workshop__c" />
<script>
// Using jQuery, hide all of the actionLinks (edit link specifically) on the Workshops
// This forces the user to click the Workshop name and then click the [Edit] button
$(".actionLink").css("display","none");
</script>
</apex:page>
I also posted an Idea to the Idea Exchange to allow easy selection of which links should appear on the standard List Views and Related Lists: https://sites.secure.force.com/ideaexchange/ideaView?c=09a30000000D9xt&id=08730000000I3uN

Very slick!!
Can this be used anyway for Standard pages?
Harshesh,
I don’t believe so. The only way to get VisualForce onto a Standard page is to drop a VisualForce component onto the page. I believe that Saleforce does this through an iFrame, where the VF page comes from a different domain (ex: c.na1.visual.force.com instead of na1.salesforce.com). Standard browser security will prevent the JavaScript on the VF page from modifying any elements on the parent page because they are on different domains.
I keep hoping that Salesforce will eventually address the shortcomings in custom buttons. I’d love to see persmissions (by Profile or Permission Set) and a formula type logic to disable the button dynamically).
Best Regards,
Mike
Anyone have any luck doing this to EnhancedLists? Would love to get some control there too. Probably not but thought I would ask ;)
Thanks..
Good idea!
Is there a way to disable action links for one specific related list only, instead of all of them?