You need to sign in to do that
Don't have an account?
Vincent van Drunen Littel
Hi,
I have a visualforce page that provides me a list with accounts and their contacts. But it is a mess and all over the place, I need to get it to be sorted alphabetically.
And if possible a search box that would search within this page
Please let me know !
Sort a VisualForce Page Alphabetically
Hi,
I have a visualforce page that provides me a list with accounts and their contacts. But it is a mess and all over the place, I need to get it to be sorted alphabetically.
And if possible a search box that would search within this page
Please let me know !
List<Account> accounts = [select Id, Name from Account order by Name]; // for ascending order on Name
List<Account> accounts = [select Id, Name from Account order by Name DESC];// for descending order
Depending on the order required you can choose the query and use the corresponding list in the visualforce page. This will display the records in the order as required for you.
The same can be done with contacts.
All Answers
List<Account> accounts = [select Id, Name from Account order by Name]; // for ascending order on Name
List<Account> accounts = [select Id, Name from Account order by Name DESC];// for descending order
Depending on the order required you can choose the query and use the corresponding list in the visualforce page. This will display the records in the order as required for you.
The same can be done with contacts.
Would you know how to create a SearchBox inside this VFpage aswell ?