You need to sign in to do that
Don't have an account?
Ryan McNeely
When user clicks the Delete Button, the product is not getting deleted from the visualforce page
Hi All,
I'm having a hard time with the controller code for my visualforce Delete Button. When the user clicks the 'X', that entire row should disappear from the view, and the object should be deleted. I've been through so many wikis on the topic. You're help would be appreciated.
(I'd also like to know how to replace the 'X' with a nifty x button .png or similar)
I'm having a hard time with the controller code for my visualforce Delete Button. When the user clicks the 'X', that entire row should disappear from the view, and the object should be deleted. I've been through so many wikis on the topic. You're help would be appreciated.
(I'd also like to know how to replace the 'X' with a nifty x button .png or similar)
<apex:page controller="SockWarehouseController" tabStyle="Sock__c"> <h1>Ocean Socks</h1> <apex:form > <apex:pageBlock title="Inventory"> <apex:pageBlockSection columns="1"> <apex:pageBlockTable value="{!products}" var="pitem"> <apex:column headerValue="" > <apex:commandButton action="{!deleteProduct}" value="X"/> </apex:column> <apex:column headerValue="Product" > <apex:outputText value="{!pitem.Name}"/> </apex:column> <apex:column headerValue="Quantity"> <apex:outputText value="{!pitem.Quantity__c}"/> </apex:column> <apex:column headerValue="Price"> <apex:outputText value="{!pitem.Price__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public class SockWarehouseController { List<Sock__c> products; public List<Sock__c> getProducts() { if(products == null) { products = [SELECT id, Name, Quantity__c, Price__c FROM Sock__c]; } return products; } public PageReference deleteProduct() { String socksId = ApexPages.currentPage().getParameters().get('id'); System.debug(socksId); Sock__c sockObject = [Select id from Sock__c where id=:socksId]; delete sockObject ; return null; } }
https://developer.salesforce.com/forums/?id=906F000000095uXIAQ
All Answers
https://developer.salesforce.com/forums/?id=906F000000095uXIAQ