You need to sign in to do that
Don't have an account?
Nervosa
Sorting custom object in a pageBlockTable
Greetings everyone!
Surfing over the Internet trying to find information about sorting on a VF pages i've found this - http://salesforcesource.blogspot.com/2008/11/adding-sorting-capability-to.html
and it was a desirable discovery BUT!! - it is ALMOST what i was searching for. The problem is that in my case there is a custom object. And that tutorial concerns only sObjects. Everything in it is applicable for my Item__c object except this part:
public PageReference ViewData() { //build the full sort expression string sortFullExp = sortExpression + ' ' + sortDirection; //query the database based on the sort expression accounts = Database.query('Select id, Name, BillingCity, BillingCountry, Phone from Account order by ' + sortFullExp + ' limit 1000'); return null; }
I don't see ways how can i do that with custom object. Please help me.
Thanks in advance.
Try building the query for your custom object instead of Accounts.
List<YourCustomObject> records = Database.query('Select <your custom object fields> from <yourcustomobject> order by ' + sortFullExp + ' limit 1000');