Delete Row Functionality via Visualforce

Delete Row Functionality via Visualforce

Delete row functionality via Visualforce comes handy when a user is required to add rows or more fields to the existing ones on a web page. This is covered in my post Adding row functionality to Existing ones on Visualforce Page. While adding rows, it is possible a user adds more rows or fields than needed. This gives rise to a use case of deleting extra rows.

To achieve this feature, Delete method was added to the Controller and for the Visualforce code <apex:pageBlockSection> was used to add the static form while <apex:pageBlockTable> was used to add the number of columns required including the Delete link.

In this post, the same custom object – Customer as in the above post is used.

Below is the User Interface (UI) that is the Visualforce page after clicking the Add button three times

Row Functionality 1

The Visualforce code used:

The Controller:

Below is the User Interface before clicking the Add button

Row Functionality 2

Notice, the static form part is not compulsory, you can tweak the code to your own advantage


This Post Has 2 Comments

  1. I am getting an error
    (Unknown constructor ‘BookNow.BookNow(ApexPages.StandardController controller)’

    1. Hi Apeksha,

      Did you use a custom controller or controller extension? If the “BookNow” is a custom controller, it will not accept a parameter. Only the controller extension takes a parameter. You can also add the code snippet so that I can take a look.



Leave a Reply

Close Menu