+ Start a Discussion
Sunita PSunita P 

Add delete link on inline Visualforce page

Hello everyone,

I have created an inline Visualforce page, I was able to create the Edit link, however, I'm unable to add the 'Del' link. I'm using a standard controller with no extentions. Below is a screenshot -

User-added image

Thank you.
 
Rahul_kumar123Rahul_kumar123
Hi Sunita,
Please check the below code.where we need to create an extension for a standard controller.
Visualforce Page
<apex:page standardController="contact" extensions="deletemultiplecont" recordSetVar="contacts" >
    <apex:form id="frm">
          <apex:pageblock id="pgblk">
            <apex:pageBlocktable value="{!contacts}" var="cont"  >
              <apex:column headerValue="Action" >
                <apex:commandlink value="delete" action="{!delmultplerec}" reRender="pgblk"> 
                   <apex:param value="{!cont.id}" name="Id" /> 

                 </apex:commandLink>
              </apex:column>
              <apex:column headerValue="Name"  value="{!cont.Name}"></apex:column>
              <apex:column headerValue="MailingCity" value="{!cont.MailingCity}" ></apex:column>
              <apex:column headerValue="Phone"  value="{!cont.phone}"></apex:column>
              </apex:pageblockTable>
    </apex:pageblock>
    </apex:form>
</apex:page>
Apex code:
public with sharing class deletemultiplecont {

   // public deletemultiplecont(ApexPages.StandardSetController controller) {

   // }
  public string Name{set;get;}
  public string Phone{get;set;}
  public string MailingCity{get;set;}
  public string asgn{get;set;}
  public contact cdel = new contact();
 
 public deletemultiplecont(apexpages.standardsetcontroller setcon)
  {
  
  }
  
  Public pagereference delmultplerec()
  {
        Id contactId = apexpages.currentpage().getParameters().get('Id');
        system.debug('hidden val is..!!' +asgn);
        try
            {
            
            cdel = [select id from contact where id =: contactId];
            system.debug('delete rec is..!!' +cdel);
            delete cdel;            
            return NULL;
            }
             catch(exception e)
             {
                System.debug('The following exception has occurred: ' + e.getMessage());
                return NULL;
             } 
  }
}

I hope it will be helpful.

Please mark it as best Answer if it resolved the problem.

Best Regards,
​RahulKumar.
Sunita PSunita P
Hi Rahul,

Thank you for your response. The solution works!

However, I using the page as an inline Visualforce page, i.e. is I'm adding the visualforce page to a standard page. It is working fine only thing is after deleting the inline page does not refresh.

Any thoughts....

Sunita