Hiding Edit Links for Related Lists/Views on a VisualForce Page

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