+ Start a Discussion
Ayush_MangalAyush_Mangal 

Exporting records in CSV through pagination using StandardSetController

I have pagination setup using StandardSetController. It is using dynamic query as it is based on seearch criteria. 
I have set the page size as 50. (Lets name this page as Page1). 

I am able to query 10000 records and show them using pagination. ( No problem till here.)
Problem lies when I want these records to be exported in csv format? 

I have created another page (suppose Page2 ). I have a button on Page1 having action as
public PageReference toExcel(){ return page.Page2; } 
On this page I am showing the records. Only 50 records are exported.

If I take 2 StandardSetController, say S1 and S2 and I query in S1 and put the result in S2 and then set the page size in S1, then also same thing is happening.

If I take 2 StandardSetController, say S1 and S2, and query differently, and put a limit of 5000, then it works fine, but then I have less no of records in query.

Any workaround?

GlynAGlynA
Since Page1 knows about all 10000 records, why not have Page1's "toExcel()" method actually do the CSV export?  Why do you need Page2?

Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
Blog: GlynATheApexGuy.blogspot.com
Twitter: @GlynAtClosedWon
Ayush_MangalAyush_Mangal
Page1 is showing records through pagination and Page2 is used for exporting records, as it need contentType also.