function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adriana VoyceAdriana Voyce 

Make Visualforce display related list only and not clickable

Hi All, 

I created a visualforce page to display a related list from a custom object. It looks great and I was able to remove the edit links as well. I would like however for the list to be read only though. I want the page to show the columns and details but I do not want the user to be able to click on the record reference to try to navigate to it. If they click on the VF page I do not want anything to happen. 

Here is my code for the page. I tried readOnly="True" but it does not seem to work. 
<apex:page standardController="SBQQ__Quote__c" readOnly="true"> <apex:relatedList list="SBQQ__LineItems__r" /> <style> [Class*='actionColumn'] { display:none; visibility:hidden; } </style> <style> [Class*='linkSpan'] { display:none; visibility:hidden; } </style> </apex:page>

Any suggestions? 
Best Answer chosen by Adriana Voyce
YogeshMoreYogeshMore
Hi Adriana,

Use following code.
<apex:page standardController="SBQQ__Quote__c" readOnly="true">
<script>
window.onload = function(){
    var x = document.getElementsByClassName(" dataCell ");
    for (k = 0; k < x.length; k++) {
        var y = x[k].getElementsByTagName("a"); 
        for (i = 0; i < y.length; i++) {
            y[i].removeAttribute('href');
        }
    }   
}
</script>

 <apex:relatedList list="SBQQ__LineItems__r" />
 <style> [Class*='actionColumn'] { display:none; visibility:hidden; } </style> 
<style> [Class*='linkSpan'] { display:none; visibility:hidden; } </style> 
</apex:page>


Let us know if it helps you.



Regards,
Yogesh More
Salesforce consultant || Salesforce Developer
more.yogesh422@gmail.com || www.yogeshmore.com 
Skype:-yogesh.more44
 
 

All Answers

Dushyant SonwarDushyant Sonwar

Hi Adriana ,

Best option is to use javascript and remove links from the related list.
As I don't know what apex:relatedList will form your html markup in your web page in your org , as I don't have access to your org
You need to inspect element ifor the  output page to findout what is your markup html forming for apex:relatedlist for javascript



Another option you can use is css to disable links using  css , it will disable navigation but it will show as links 
a{
pointer-events: none;
cursor: default;

}

 

Hope this helps

Dushyant SonwarDushyant Sonwar
Adrianna , 
If you don't want to use javascript and css for this , then you can also use apex:pageblockTable to show your data.
You need to just replace apex:relatedlist tag to apex:pageBlockTable
Below is just a small example :)
<apex:pageblockTable value="{!SBQQ__LineItems__r}" var="lineitemObj">
<apex:column name="{!lineitemObj.Name}">
</apex:pageBlockTable>
https://help.salesforce.com/apex/HTViewSolution?urlname=Customizing-related-Lists-Using-VisualForce-and-Apex-1327107624263&language=en_US
YogeshMoreYogeshMore
Hi Adriana,

Use following code.
<apex:page standardController="SBQQ__Quote__c" readOnly="true">
<script>
window.onload = function(){
    var x = document.getElementsByClassName(" dataCell ");
    for (k = 0; k < x.length; k++) {
        var y = x[k].getElementsByTagName("a"); 
        for (i = 0; i < y.length; i++) {
            y[i].removeAttribute('href');
        }
    }   
}
</script>

 <apex:relatedList list="SBQQ__LineItems__r" />
 <style> [Class*='actionColumn'] { display:none; visibility:hidden; } </style> 
<style> [Class*='linkSpan'] { display:none; visibility:hidden; } </style> 
</apex:page>


Let us know if it helps you.



Regards,
Yogesh More
Salesforce consultant || Salesforce Developer
more.yogesh422@gmail.com || www.yogeshmore.com 
Skype:-yogesh.more44
 
 
This was selected as the best answer
Adriana VoyceAdriana Voyce
Thank you YogRaj it worked. Dushyant Sonwar I tried your solutinons, but I am only learning to write code so perhaps that is why I could not get it tow. 

The answer YogRaj worked great, however, the reason why I wanted the visualforce page of the related list is because I want to remove the visualforce page from the layout. When I did that, the columns from the VF page disappered and reset to show only the record name :( any ideas on how I can have it shows the columns from the related list without the list its self being on the layout?