You need to sign in to do that
Don't have an account?

Visualforce List View Page with Edit and Delete
I have a controller which aids in displaying a visualforce page with the Edit & delete functionality.However, my delete doesn't seem to work.
Kindly assist.Am using this post as a guide:
public class OrderDealsExtension { public List<Deals__c> deals {get;set;} public String SelectedDealId {get;set;} public OrderDealsExtension() { loadData(); } public void loadData() { deals = [Select id,Name,Deal_Start_Date__c,Candidates__c,Contact__c,Deal_End_Date__c,Deal_Type__c,Deal_Buy_Price__c,Deal_Client_Rate__c,CreatedDate from Deals__c Order By CreatedDate desc]; } public void deleteDeal(){ if(SelectedDealId == null){ return; } //find the deal record within the collection Deals__c tobeDeleted = null; for(Deals__c d :deals){ if(d.Id == SelectedDealId){ tobeDeleted = d; break; } //if deal record found delete it if(tobeDeleted != null){ Delete tobeDeleted; } //refresh the data loadData(); } } }
Visualforce Page.
<apex:page controller="OrderDealsExtension"> <apex:form id="form" > <apex:pageBlock title="Deals"> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockTable value="{!deals}" var="d"> <apex:column > <apex:outputLink title="" value="/{!d.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink> | <a href="javascript:if (window.confirm('Are you sure?')) deleteDeal('{!d.Id}');" style="font-weight:bold">Del</a> </apex:column> <apex:column headervalue="Order Number" > <apex:outputLink value="/{!d.id}"> <apex:outputField value="{!d.Name}"/> </apex:outputLink> </apex:column> <apex:column value="{!d.Candidates__c}" /> <apex:column value="{!d.Contact__c}" /> <apex:column value="{!d.Deal_Start_Date__c}" /> <apex:column value="{!d.Deal_End_Date__c}" /> <apex:column value="{!d.Deal_Buy_Price__c}" /> <apex:column value="{!d.Deal_Client_Rate__c}" /> </apex:pageBlockTable> </apex:pageBlock> <apex:actionFunction action="{!deleteDeal}" name="DeleteDeal" reRender="form" > <apex:param name="dealid" value="" assignTo="{!SelectedDealId}"/> </apex:actionFunction> </apex:form> </apex:page>
I got another simple way of doing it.I used the commandlink function instead of ActionFunction on my VF and also simplified my Delete method in my controller:
All Answers
I got another simple way of doing it.I used the commandlink function instead of ActionFunction on my VF and also simplified my Delete method in my controller:
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000kEck