You need to sign in to do that
Don't have an account?
eriktown
Displaying more than 20 Contacts with the Contacts standard controller
Hello folks,
I'm using the Contacts standard controller to display a list of the user's contacts; the user then can click a button to select a particular contact. But I'm finding that the controller list method isn't allowing me to display more than 20 contacts at once. Is there any way to make it list all contacts, instead of the first 20? Failing that, is there a way to display the next section of the list?
Thank you in advance!
Presumably you are using the standard list controller? That being the case you have built-in support for pagination, e.g.
If you want to change the number of records displayed on a page, you'll need to set the pagesize on the standard controller, which probably means an extension controller.
All Answers
Presumably you are using the standard list controller? That being the case you have built-in support for pagination, e.g.
If you want to change the number of records displayed on a page, you'll need to set the pagesize on the standard controller, which probably means an extension controller.
Thank you very much for your response, Bob.
I've already got an extension controller for that particular page due to another operation I'm performing. But I'm not sure how to set the page size - I see that there is a setPageSize method on the StandardSetController, but I can't find one for the Contacts controller. Do I need to instantiate a StandardSetController? If so how do I make it apply to the Contacts controller I'm already using?
Are you using a standard list controller or a standard controller? I'm assuming the former given the 20 per page.
In that case, your extension controller should have a constructor that takes ApexPages.StandardSetController as a parameter - do you have one of those?
Oh! You're right, I do. So I'd just call setPageSize on that?
That's my understanding. Let us know if that does it :)
I am pleased to announce that it works just as expected. :)
I don't suppose you know if there is a way to supress the "Previous" link if we're on the first page of the list?
The standard controller has a getPageNumber that returns 1 if you are on the first page.
Thus you should be able to have something like: