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
tk.servicetk.service 

StandardSetController cancel() and save() issue

Hi,

 

I have a visualforce page where I populate a PageBlockDataTable with a list<sObject> using StandardSetController.getRecords(). There are some fields in the table that are inputFields to allow edits. Pagination is implemented and works fine if nothing is edited.

 

I read that either cancel() or save() needs to be run before moving to another page otherwise visualforce will throw an error saying 'modified rows exist in the collection'. So when records are edited, I have a javascript that detect changes and prompts user whether to save or cancel before moving to next page, which then through calling actionFunction runs the StandardSetController's cancel() / save() and then next() / previous() / setPageNumber(x) in a method in the page's controller.

 

Problem: After running that, let's say cancel() and next(), getResultSize() becomes lesser and the collection shrunk. Although getPageNumber() appear to be working, something is wrong as there are lesser pages now in the paginated table. Debug log shows that getResultSize() has indeed become lesser after ApexPages.StandardSetController.cancel() is run.

 

Any idea what could be wrong? any feedback/solution recommended is much appreciated. Thanks.

 

 

mgodseymgodsey
Were you ever able to figure this out? I am currently facing a similar issue.