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
Sekhar SekharSekhar Sekhar 

when click on account name then display the popup along with same account name record details

HI 
In my vf page i am displating all account records (by using  <apex:pageBlockTable> ) it is done  here my problem is 
when i am click on account name ( any one from displayed account names) then immediately display one popup in that popup should display that account name  record details 
 
 
Best Answer chosen by Sekhar Sekhar
Akhilesh Reddy BaddigamAkhilesh Reddy Baddigam
//VF PAGE

<apex:page standardController="Account" recordSetVar="accounts" extensions="tstpopup">
    <apex:form >
        
        <apex:pageBlock >
            
      
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">
      
        <apex:column headerValue="Account Name">
          <apex:commandLink action="{!showPopup}" >
              <apex:param name="nickName"
                value="{!a.Name}"
                assignTo="{!acctName}"/>
              {!a.Name}
              </apex:commandLink> 
       </apex:column>
        <apex:column value="{!a.createdById}"/>
      </apex:pageBlockTable>
            
        </apex:pageBlock>
        
        
 
        <apex:outputPanel id="tstpopup">
        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
                <apex:outputText value="{!acctName}"></apex:outputText>
                
                
               
                <br/><br/><br/>
                <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="tstpopup"/>
            </apex:outputPanel>
        </apex:outputPanel>
 
    </apex:form>
 
    <style type="text/css">
        .custPopup{
            background-color: white;
            border-width: 2px;
            border-style: solid;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;
            /* These are the 3 css properties you will need to change so the popup 
            displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can add 
            the height property for a fixed size pop up if you want.*/
            width: 500px;
            margin-left: -250px;
            top:100px;
        }
        .popupBackground{
            background-color:black;
            opacity: 0.20;
            filter: alpha(opacity = 20);
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9998;
        }

    </style>
</apex:page>


//Controller

public class tstpopup {
    public tstpopup(ApexPages.StandardSetController s){
       
        
    }
    public String acctName{
        get;
    
        set;
                              
                          
    }
    public boolean displayPopup {get; set;}  
    public account a{get;set;}
    
    public void closePopup() {        
        displayPopup = false;  
    }     
    public void showPopup() {        
        
        displayPopup = true;
        
    }
  
    
    
  }

As we can find in this link (https://developer.salesforce.com/forums/?id=906F000000097X9IAI), we can use this pop up modal and display the necessary data for the corresponding account using commandLink and paramters, you can find the above code which achieves the same, depending on your acoount details to be displayed feel free to add some getter setters to display necessary data however if you need to display all the details for that account which is not suggestable to achive in a modal view. follow this link to open in a new window. (https://www.youtube.com/watch?v=zoSmVnVKEzs)

If this solves your problem please choose this as the best answer.
Thank you!

All Answers

NatsuNatsu
<apex:page controller="AccountDetails">
<script>

    function display(account,id){
    alert('Name :'+account+'\nId :'+id);
    
    }
    
</script>
<h1>Viewing Accounts</h1>
     <apex:repeat value="{!accounts}" var="a">
         <p onclick="display('{!a.name}','{!a.id}')">{!a.name}</p>
        
     </apex:repeat>

</apex:page>

You can proceed with something along the above lines. For popups refer to modals of framework like bootstrap https://www.w3schools.com/bootstrap/bootstrap_modal.asp (https://www.w3schools.com/bootstrap/bootstrap_modal.asp" target="_blank)
Akhilesh Reddy BaddigamAkhilesh Reddy Baddigam
//VF PAGE

<apex:page standardController="Account" recordSetVar="accounts" extensions="tstpopup">
    <apex:form >
        
        <apex:pageBlock >
            
      
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">
      
        <apex:column headerValue="Account Name">
          <apex:commandLink action="{!showPopup}" >
              <apex:param name="nickName"
                value="{!a.Name}"
                assignTo="{!acctName}"/>
              {!a.Name}
              </apex:commandLink> 
       </apex:column>
        <apex:column value="{!a.createdById}"/>
      </apex:pageBlockTable>
            
        </apex:pageBlock>
        
        
 
        <apex:outputPanel id="tstpopup">
        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
                <apex:outputText value="{!acctName}"></apex:outputText>
                
                
               
                <br/><br/><br/>
                <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="tstpopup"/>
            </apex:outputPanel>
        </apex:outputPanel>
 
    </apex:form>
 
    <style type="text/css">
        .custPopup{
            background-color: white;
            border-width: 2px;
            border-style: solid;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;
            /* These are the 3 css properties you will need to change so the popup 
            displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can add 
            the height property for a fixed size pop up if you want.*/
            width: 500px;
            margin-left: -250px;
            top:100px;
        }
        .popupBackground{
            background-color:black;
            opacity: 0.20;
            filter: alpha(opacity = 20);
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9998;
        }

    </style>
</apex:page>


//Controller

public class tstpopup {
    public tstpopup(ApexPages.StandardSetController s){
       
        
    }
    public String acctName{
        get;
    
        set;
                              
                          
    }
    public boolean displayPopup {get; set;}  
    public account a{get;set;}
    
    public void closePopup() {        
        displayPopup = false;  
    }     
    public void showPopup() {        
        
        displayPopup = true;
        
    }
  
    
    
  }

As we can find in this link (https://developer.salesforce.com/forums/?id=906F000000097X9IAI), we can use this pop up modal and display the necessary data for the corresponding account using commandLink and paramters, you can find the above code which achieves the same, depending on your acoount details to be displayed feel free to add some getter setters to display necessary data however if you need to display all the details for that account which is not suggestable to achive in a modal view. follow this link to open in a new window. (https://www.youtube.com/watch?v=zoSmVnVKEzs)

If this solves your problem please choose this as the best answer.
Thank you!
This was selected as the best answer
Sekhar SekharSekhar Sekhar
Thank You Akhilesh Reddy Baddigam
Sekhar SekharSekhar Sekhar
Thanks Natsu