You need to sign in to do that
Don't have an account?
G2WIntegration
How to Repeat a Delete Button in List w/ Different Row Target
Salesforce lists have a View & Del link for every row. I know how to make the view link, but haven't been able to figure out how to get any other action to target that specific row.
Currently I'm using Dynamic Binding to show the list as the target is a protected custom setting, but I can probably use any list code like a pageBlockTable if that's easier. The use case here is to show the name of each row (which is the userId), and delete the row using a button, similar to Salesforce lists.
Current sample code:
<apex:page standardController="Account" extensions="DynamicAccountFieldsLister"> <apex:pageMessages /><br/> <apex:form> <apex:pageBlock title="Edit Account" mode="edit"> <apex:pageBlockSection columns="1"> <apex:commandLink value="View" action="/{!r.Id}"/> <apex:repeat value="{!editableFields}" var="f"> <apex:inputField value="{!Account[f]}"/> </apex:repeat> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public class DynamicAccountFieldsLister { public DynamicAccountFieldsLister(ApexPages.StandardController controller) { controller.addFields(editableFields); } public List<String> editableFields { get { if (editableFields == null) { editableFields = new List<String>(); editableFields.add('Industry'); editableFields.add('AnnualRevenue'); editableFields.add('BillingCity'); } return editableFields ; } private set; } }
If you are iterating a list of sobjects, the easiest way to do this is to make the delete a commandlink and set the record id as a parameter. Then in your delete action method, the id will be populated by the time it is executed.
I've probably explained this better at:
http://bobbuzzard.blogspot.co.uk/2011/07/passing-parameters-to-apex-method-from.html
All Answers
If you are iterating a list of sobjects, the easiest way to do this is to make the delete a commandlink and set the record id as a parameter. Then in your delete action method, the id will be populated by the time it is executed.
I've probably explained this better at:
http://bobbuzzard.blogspot.co.uk/2011/07/passing-parameters-to-apex-method-from.html
Thanks - that worked!
Update - I didn't originally figure out that "all" was the Id of your outputPanel so I was thinking that was a reserved word for "the entire page". Once I added an Id to the section, the list rerendered nicely.