function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chanagan SakulteeraChanagan Sakulteera 

How to copy data from previous row when trying to add new row in visualforce page ?

Hi all, I'm new to salesforce

I have question regarding visualforce page. When I try to add a new row in visualforce page , I want to copy the data form previous row to new row as well how would I do that ? Any suggustion, I would really appreciate.

Thank you

 User-added image

Best Answer chosen by Chanagan Sakulteera
James LoghryJames Loghry
Have you written any code for this yet?

Looks like you have a list of records or a list of wrapper classes, which is great.  Your Add Row (commandButton) should call an action in your extension/controller that reads from the last row in your list, then creates a new instance of the object or wrapper or whatever is in your list, and then populates it.  This action should return a null page reference, and then the command button should rerender your table to show the new row.

 

All Answers

James LoghryJames Loghry
Have you written any code for this yet?

Looks like you have a list of records or a list of wrapper classes, which is great.  Your Add Row (commandButton) should call an action in your extension/controller that reads from the last row in your list, then creates a new instance of the object or wrapper or whatever is in your list, and then populates it.  This action should return a null page reference, and then the command button should rerender your table to show the new row.

 
This was selected as the best answer
Chanagan SakulteeraChanagan Sakulteera
Thank you for your answer so much Jame Loghry. I understand how it works now.