Skip to main content
deleted 901 characters in body
Source Link

I have a visualforce page which shows list of a custom object records.One column shows the Account name which has lookup relationship with the custom object.I need to add one button in each row and on click this will show the contact records for that account only in a different vf page.I have tried passing the account id in the vf page that I have created for contact list.But it gets redirected to account record.

Thanks for help!


//custom object records
        public List getCustomObjectRec()
        {
        return (List) setController.getRecords();
        }
        //page reference
        public PageReference showContacts(){       
        PageReference pr = Page.MyContactListPage;
        pr.getParameters().put('accountId','Account ID');
        return pr;
        }

<apex:dataTable width="100%" value="{!CustomObjectRec}" var="obj">
 <apex:column width="15%">
  <apex:facet name="header">
   <apex:outputPanel layout="inline">
     <apex:commandLink value="Client">
      <apex:param assignTo="{!accountname}" value="acc_Name"/>
     </apex:commandLink >         
   </apex:outputPanel>
</apex:facet>
<apex:outputLink value="/{!obj.Account__c}">{!obj.Account__r.Name}/apex:outputLink>
</apex:column>


<apex:column width="5%" styleClass="mainTableRow">
 <apex:facet name="header">/apex:facet>
  <apex:panelGrid columns="4" width="100%">
   <apex:commandButton value="Show Contacts" action="{!showContacts}">
    <apex:param name="accountId" value="{!obj.Account__r.Id}" assignTo="{!accountId}"/>
   </apex:commandButton>
  </apex:panelGrid>
 </apex:column>
</apex:dataTable>

I have a visualforce page which shows list of a custom object records.One column shows the Account name which has lookup relationship with the custom object.I need to add one button in each row and on click this will show the contact records for that account only in a different vf page.I have tried passing the account id in the vf page that I have created for contact list.But it gets redirected to account record.

Thanks for help!


//custom object records
        public List getCustomObjectRec()
        {
        return (List) setController.getRecords();
        }
        //page reference
        public PageReference showContacts(){       
        PageReference pr = Page.MyContactListPage;
        pr.getParameters().put('accountId','Account ID');
        return pr;
        }

<apex:dataTable width="100%" value="{!CustomObjectRec}" var="obj">
 <apex:column width="15%">
  <apex:facet name="header">
   <apex:outputPanel layout="inline">
     <apex:commandLink value="Client">
      <apex:param assignTo="{!accountname}" value="acc_Name"/>
     </apex:commandLink >         
   </apex:outputPanel>
</apex:facet>
<apex:outputLink value="/{!obj.Account__c}">{!obj.Account__r.Name}/apex:outputLink>
</apex:column>


<apex:column width="5%" styleClass="mainTableRow">
 <apex:facet name="header">/apex:facet>
  <apex:panelGrid columns="4" width="100%">
   <apex:commandButton value="Show Contacts" action="{!showContacts}">
    <apex:param name="accountId" value="{!obj.Account__r.Id}" assignTo="{!accountId}"/>
   </apex:commandButton>
  </apex:panelGrid>
 </apex:column>
</apex:dataTable>

I have a visualforce page which shows list of a custom object records.One column shows the Account name which has lookup relationship with the custom object.I need to add one button in each row and on click this will show the contact records for that account only in a different vf page.I have tried passing the account id in the vf page that I have created for contact list.But it gets redirected to account record.

Thanks for help!


<apex:column width="5%" styleClass="mainTableRow">
 <apex:facet name="header">/apex:facet>
  <apex:panelGrid columns="4" width="100%">
   <apex:commandButton value="Show Contacts" action="{!showContacts}">
    <apex:param name="accountId" value="{!obj.Account__r.Id}" assignTo="{!accountId}"/>
   </apex:commandButton>
  </apex:panelGrid>
 </apex:column>
</apex:dataTable>

added 1374 characters in body
Source Link

I have a visualforce page which shows list of a custom object records.One column shows the Account name which has lookup relationship with the custom object.I need to add one button in each row and on click this will show the contact records for that account only in a different vf page.I have tried passing the account id in the vf page that I have created for contact list.But it gets redirected to account record.

  

Thanks for help!


//custom object records
        public List getCustomObjectRec()
        {
        return (List) setController.getRecords();
        }
        //page reference
        public PageReference showContacts(){       
        PageReference pr = Page.MyContactListPage;
        pr.getParameters().put('accountId','Account ID');
        return pr;
        }

<apex:dataTable width="100%" value="{!CustomObjectRec}" var="obj">
 <apex:column width="15%">
  <apex:facet name="header">
   <apex:outputPanel layout="inline">
     <apex:commandLink value="Client">
      <apex:param assignTo="{!accountname}" value="acc_Name"/>
     </apex:commandLink >         
   </apex:outputPanel>
</apex:facet>
<apex:outputLink value="/{!obj.Account__c}">{!obj.Account__r.Name}/apex:outputLink>
</apex:column>


<apex:column width="5%" styleClass="mainTableRow">
 <apex:facet name="header">/apex:facet>
  <apex:panelGrid columns="4" width="100%">
   <apex:commandButton value="Show Contacts" action="{!showContacts}">
    <apex:param name="accountId" value="{!obj.Account__r.Id}" assignTo="{!accountId}"/>
   </apex:commandButton>
  </apex:panelGrid>
 </apex:column>
</apex:dataTable>

I have a visualforce page which shows list of a custom object records.One column shows the Account name which has lookup relationship with the custom object.I need to add one button in each row and on click this will show the contact records for that account only in a different vf page.I have tried passing the account id in the vf page that I have created for contact list.But it gets redirected to account record.

  Thanks for help!

I have a visualforce page which shows list of a custom object records.One column shows the Account name which has lookup relationship with the custom object.I need to add one button in each row and on click this will show the contact records for that account only in a different vf page.I have tried passing the account id in the vf page that I have created for contact list.But it gets redirected to account record. 

Thanks for help!


//custom object records
        public List getCustomObjectRec()
        {
        return (List) setController.getRecords();
        }
        //page reference
        public PageReference showContacts(){       
        PageReference pr = Page.MyContactListPage;
        pr.getParameters().put('accountId','Account ID');
        return pr;
        }

<apex:dataTable width="100%" value="{!CustomObjectRec}" var="obj">
 <apex:column width="15%">
  <apex:facet name="header">
   <apex:outputPanel layout="inline">
     <apex:commandLink value="Client">
      <apex:param assignTo="{!accountname}" value="acc_Name"/>
     </apex:commandLink >         
   </apex:outputPanel>
</apex:facet>
<apex:outputLink value="/{!obj.Account__c}">{!obj.Account__r.Name}/apex:outputLink>
</apex:column>


<apex:column width="5%" styleClass="mainTableRow">
 <apex:facet name="header">/apex:facet>
  <apex:panelGrid columns="4" width="100%">
   <apex:commandButton value="Show Contacts" action="{!showContacts}">
    <apex:param name="accountId" value="{!obj.Account__r.Id}" assignTo="{!accountId}"/>
   </apex:commandButton>
  </apex:panelGrid>
 </apex:column>
</apex:dataTable>

Source Link

how to get the id of a record in a row?

I have a visualforce page which shows list of a custom object records.One column shows the Account name which has lookup relationship with the custom object.I need to add one button in each row and on click this will show the contact records for that account only in a different vf page.I have tried passing the account id in the vf page that I have created for contact list.But it gets redirected to account record.

Thanks for help!