1

I have a record table. I want to make product brief number clickable. When user click on the product brief number it will take to the record (open the product brief). Does anybody have idea? Thanks enter image description here

<apex:page standardController="Product_Brief__c" extensions="DispatcherContactNewController">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!pbs}" var="p">
            <tr class="lnkdsble" ><apex:column value="{!p.Name}"/></tr>
            <apex:column value="{!p.RecordTypeId}"/>
            <apex:column value="{!p.Createddate}"/>
            </apex:pageBlockTable> 
        </apex:pageBlock>

        <apex:panelGrid columns="4">
            <apex:commandLink action="{!first}">First</apex:commandlink>
            <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
            <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
            <apex:commandLink action="{!last}">Last</apex:commandlink>
        </apex:panelGrid>
     </apex:pageBlock>
   </apex:form>
</apex:page>

Extension

    public class DispatcherContactNewController {

        public DispatcherContactNewController(ApexPages.StandardController controller) {
            this.controller = controller;
        }

        public ApexPages.StandardSetController setpb {
            get{
                if (setpb == null) {
                    setpb = new ApexPages.StandardSetController(Database.getQueryLocator(
                        [SELECT Id, Name, RecordTypeId, Createddate FROM Product_Brief__c])
                                                               );
                }
                return setpb;
            }
            set;
        }

        public List<Product_Brief__c>getpbs() {
            return (List<Product_Brief__c>)setpb.getrecords();
        }

        public Boolean hasNext {
            get {
                return setpb.getHasNext();
            }
            set;
        }

        public Boolean hasPrevious {
            get {
                return setpb.getHasPrevious();
            }
            set;
        }

        public Integer pageNumber {
            get {
                return setpb.getPageNumber();
            }
            set;
        }

        public void first() {
            setpb.first();
        }

        public void last() {
            setpb.last();
        }


        public void previous() {
            setpb.previous();
        }


        public void next() {
            setpb.next();
        }
    }

Code

 <apex:pageBlock title="Recent Product Briefs">
    <apex:pageBlockTable value="{!pbs}" var="p" >
        <apex:column > 
            <apex:facet name="header">Product Brief Number</apex:facet>
            <a href="/{!p.Id}" id="{!p.Id}" target="_blank"
                   onblur="LookupHoverDetail.getHover('{!p.Id}').hide();" 
                   onfocus="LookupHoverDetail.getHover('{!p.Id}', '/{!p.Id}/m?retURL=%2F{!p.Id}&isAjaxRequest=1').show();" 
                   onmouseout="LookupHoverDetail.getHover('{!p.Id}').hide();" 
                   onmouseover="LookupHoverDetail.getHover('{!p.Id}', '/{!p.Id}/m?retURL=%2F{!p.Id}&isAjaxRequest=1').show();">{!p.Name}</a>
        </apex:column>
        <apex:column value="{!p.RecordTypeId}"/>
        <apex:column value="{!p.Createddate}"/>
    </apex:pageBlockTable> 
</apex:pageBlock>
4

You could do this

<apex:column>
    <apex:outputLink value="/{!p.Id}"> {!p.Name} </apex:outputLink>
</apex:column>

instead of this

<apex:column value="{!p.Name}"/>

By doing this you'll be generating a link within the column to /(YourRecordId) which will be your record, while retaining the record name for the user to see.

2

You can also retrieve a hover mini page layout of the object like this :

<a href="/{!p.Id}" id="{!p.Id}" target="_blank"
           onblur="LookupHoverDetail.getHover('{!p.Id}').hide();" 
           onfocus="LookupHoverDetail.getHover('{!p.Id}', '/{!p.Id}/m?retURL=%2F{!p.Id}&isAjaxRequest=1').show();" 
           onmouseout="LookupHoverDetail.getHover('{!p.Id}').hide();" 
           onmouseover="LookupHoverDetail.getHover('{!p.Id}', '/{!p.Id}/m?retURL=%2F{!p.Id}&isAjaxRequest=1').show();">
           {!p.Name}</a>

This can be helpful if you want to display additional fields on hover.

  • Its work and really nice. Appreciate your help. – Suneth Jul 1 '15 at 19:53
  • Hey, Its work fine but do you know why it does not wok when i click on the link? (When hover over it has a button called view. It works fine but when you click one the link before hover over it will break the page. Any idea thanks ) – Suneth Jul 2 '15 at 21:35
  • the link should work as well you have it in your href=""...if you share your code I can be more specific...but if it doesn't maybe try to add onclick="/{p.Id}" event.. – sfdx bomb Jul 3 '15 at 6:52
  • Hi Yuval, Thanks For helping me out. I added a code section for more details. I try to add onclick="/{p.Id}". Still the same case, when i click on the link it does not work. Thanks – Suneth Jul 7 '15 at 14:41
  • 1
    sorry..seems like everything is in order - it worked for me.. :) – sfdx bomb Jul 8 '15 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.