Visualforce Page allows to modify multiple records via inlineEditSupport. How to update only records that really changed

Yes that is possible. I am not going to write the code here but I can give you an idea or approach.

Option 1:

What I suggest first is to create an inner class that will have 3 variables:

1) The sObject record

2) Integer to keep track of the index in the table

3) Boolean to keep track whether there were changes made to that row

Once you create objects of the class above for all your records, add them to a map or a list which you will later use to display the records on the page.

On each of your input fields, add actionSupport or javascript onchange event together with an actionFunction which will call a method in your class that will iterate through the map or list of your inner class objects and once it finds the changed index, it will mark that object with "changes have been made".

Lastly when the user clicks save, you loop through your map or list of inner class objects, you find the ones with the boolean variable indicating that changes have been made set to true and you add only them in a separate list which you will update later.

Option 2:

Alternatively, put the records in a map and keep a clone of that map. One of the maps would be used to display the records on the page (and will have the changed sObjects) and the other map will keep the original records once loaded from the database. On save, go through the changed map and compare the cloned record's fields in the original map. If one of the fields don't match, you add that record in a separate list used to update at the end.


1) Create a clone of the map, do not use only a reference because that will change the record in both maps.

2) You can use the schema.describe methods to compare the fields dynamically.

3) Indexes in the maps must be the same so that you can get the correct corresponding sObject

I believe there are other ways of doing it, but these are the 2 that I could think of straight away and I'd use one of these depending on the complexity of your page and number of fields you're working with.