0

I have the following:

I have a table element populated by <apex:repeat>, which works fine. However I have some Javascript that appends a new blank row to the end of the table and while I have no problem saving the existing records populated by the repeat tags, I'm having trouble on how to create new records from the new appended rows.

My idea was to do something like the following, but I'd love to know if there's an easier way:

  1. For each row, create a new JSON object.
  2. Using <apex:hidden>, push the array of JSON records into the field and bind it with a property on the controller.
  3. When running the save method on the controller, parse the JSON string and create the records based off that.

Is there an easier way to do this?

3
  • 1
    I believe your JSON approach would complicate the things. Instead maintaining a sync between controller variable binding to table rows would be better idea. Some ajax components like apex:actionfunction can be used to accomplish same. – Mukesh Verma Jun 9 '16 at 11:08
  • Please check this SFSE link. I have provided a similar solution here. – Saroj Bera Jun 9 '16 at 11:16
  • @MukeshVerma Can you give me an example of how to bind? I can't use apex components for the fields but if I can bind default html elements with controller that would be great. – user24634 Jun 9 '16 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy