Dynamically Add/Remove rows from a table in visualforce
5:31 PM
Screenshot:
The example below illustrates the way to REMOVE any given row in a table in visualforce and ADD new rows.
The REMOVE button only removes the contact from the UI.
The REMOVED rows are deleted from the database when the "SAVE Changes" button is clicked.
To execute this example include a valid Account ID in the URL as below
https://na5.salesforce.com/apex/deleteRowsExample?id=0017000000UIvsg
VF PAGE: deleteRowsExample
Apex Controller: deleteRowsExample
The example below illustrates the way to REMOVE any given row in a table in visualforce and ADD new rows.
The REMOVE button only removes the contact from the UI.
The REMOVED rows are deleted from the database when the "SAVE Changes" button is clicked.
To execute this example include a valid Account ID in the URL as below
https://na5.salesforce.com/apex/deleteRowsExample?id=0017000000UIvsg
VF PAGE: deleteRowsExample
Apex Controller: deleteRowsExample
4 comments
I think its better to check if deleteContactList is not null too before checking the size, if deleteContactList is null it can throw null pointer exception on size
ReplyDeleteNot really, DML on null lists is allowed.
DeleteIt can't be null, the deleteContactList list is initialised at the top.
DeleteThanks for this! As others suggested, a query string of ?id=[ACCOUNT-ID] needs to be added to the URL.
ReplyDelete