You need to sign in to do that
Don't have an account?
viv1
Best way to sort table when header is clicked ??
my <apex:datatable> has multiple columns containing input field ... selectList...
is it possible to sort my table when header is clicked ??
and if yes... which is best way..using controller function or jquery plugin ??
i have tried tableSorter plugin but its not working properly.....
Hi,
You can use this javascript into visualforce page, the best practise for this is save a .js into local resources in salesforce.com, but if you want try it copy an paste this code between "<javascript></javascrip>" tags:
To use the functionality you need link the datatable or table like this "styleClass='sortable'"
I hope this can help you.
Regards!
I'm not much of a javascript fan, so as long as not really necessary I prefer not using it. For sorting of a column, if you do not have too many records in that table, I think it will be more simpler and clean to simply requery the records and re-render your table.
Something like:
- When user clicks on Name Column header in the table, you'll call an actionFunction which will hit the server, requery the records such as "Select Name, Id, .... From Contact Where .... ORDER BY NAME ASC/DESC".
- On your page, simply rerender that section.