You need to sign in to do that
Don't have an account?

Pagination and Sort by Column Name Click
Hi All,
Has anyone been able to create a Visualforce Page that shows a table which has pagination (next and previous) and the ability to click a column name to sort? There seems to be lots of one or the other but not both at the same time.
I have created a table using the ApexPages.StandardSetController which has allowed me to do pagnination on the table but I can't seem to find a solution to sort by clicking the column name which works with the standardsetcontroller.
Any code examples or links to blogs that may help would be really appreciated.
Bingo!! I think you are looking for this :
http://forceguru.blogspot.com/2011/04/pagination-in-salesforce.html
Thanks
Ankit Arora
Blog | Facebook | Blog Page
That's great for pagnination and a similar approach to what I already have but how do you add the ability to sort by when clicking a column header name??
Thanks
Kev
Hi all,
I have attempted this myself using code out there on the net and the forum and have come up with the following:
Could everyone look over my code and see if there are any flaws in it. I'm new to Apex Coding so it has been a bit or trial and error as I don't fully understand it yet so can't tell if I made a mistake somewhere.
I have tested the code with the limited records I have in my org and the Visual Page seems to work. Currently it is set with page size 4 for testing, but it allows you to sort by pressing a column header name and then go next or previous with the pages and seems to keep the ordering while going through the pages.
Thanks
Kev
Visual Force Page:
Apex Class:
Hi,
I tried the above code for opportunities instead of accounts. For less opportunities it is working fine. But it is giving me error "Maximum view state size limit(135KB) exceeded. Actual view state for this page was 279.04KB" for near about 200 opportunities.
Hi,
I'm using the code for smaller amounts of data so that is possibly why I haven't got this error. Did a search I found this:
View state size issue occurs when the variables declared as public are storing data greater than 135KB. So it is better to declare these variables as transient.
Transient Keyword: Use the transient keyword to declare instance variables that can't be saved, and shouldn't be transmitted as part of the view state for a Visualforce page.
For more detail follow the below link :
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_keywords_transient.htm
Looks like if you have the Development Mode Footer turned on and you also turn on the View State Tab for it you can check which variable it taking the kilobytes. Then I guess you could set the variable as transient and it may fix the problem.
Please let me know how you get on.
Kev