You need to sign in to do that
Don't have an account?
dou
Get the id of a row table and delete the row
Hello,
I have to create a button which allow to delete a row in a visualforce table.
Here is the part of the visualforce code :
And the part of my controller:
I have to retrieve the id of the row I have to delete (when the link is clicked) and apply the supprClient() method to that id ?
But I don't know how to do that, my code doesn't work, and I get an error when I want to save my visualforce page : supprClient unknown...
Thank you
I have to create a button which allow to delete a row in a visualforce table.
Here is the part of the visualforce code :
<apex:form> <apex:repeat value="{!listClient}" var="lc"> <div class="tr"> <span class="cell"> <apex:outputLink value="{!supprClient(lc.Id)}" styleClass="delete"> <apex:param name ="rowId" value="{!supprClient(lc.Id)}"/> </apex:outputLink> </span> <span class="cell">{!lc.LastName}</span> <span class="cell">{!lc.FirstName}</span> </div> </apex:repeat> </apex:form>
And the part of my controller:
public List<Contact> listClient { get; set; } public ExtranetV2_CampagnesController() { listClient = new List<Contact>(); } public void supprClient(){ String myId = System.currentPageReference().getParameters().get('rowId'); for(Contact c : listClient){ c = [SELECT Id FROM Contact WHERE Id = :myId]; delete(c); } }
I have to retrieve the id of the row I have to delete (when the link is clicked) and apply the supprClient() method to that id ?
But I don't know how to do that, my code doesn't work, and I get an error when I want to save my visualforce page : supprClient unknown...
Thank you
For apply method you need use apex:commandLink instead of apex:outputLink
Use
instead of
Thanks,
Alex
All Answers
For apply method you need use apex:commandLink instead of apex:outputLink
Use
instead of
Thanks,
Alex
Rupal
@Rupal Kumar the apex:actionFunction won't work since I have to use an apex:repeat....
@Alexander Tsitsura your solutions seems to work, but it seems that my function for deleting the rows don't work like I want : it delete the record from my database (I think) but I just want it to delete it from my visualforce page, not completlt, just I want not be able to see the row, but I d'ont want to delete the record... Do you have any ide about that ?
Thank you again !
see code below
Thanks,
Alex