I am definitely late to the jquery party. In the last year or so, I've been able to harness jquery to make pages more usable and functional and just finished a poc for another beautiful jquery solution for a recurring visualforce requirement: sortable tables.
A colleague and I were doing a peer review on a visualforce page he had built. The page had a sortable pageblocktable, which he had enabled with a custom compare function he had built in his controller. Now, I've seen all kinds of ways of doing sorting in the controller and have done some suboptimal server-side sorting, but I never really thought about trying to keep it client-side. I figured there'd be a way with javascript but I just didn't have it in me to try to code it up. So, I poked around the google and sure enough, there's a jquery plugin already built to do it. And, sure enough, another Salesforce developer, shared her solution using the tablesorter plugin years ago.
So, a few years late to the party :)
Anyway, I wanted to share my variation since I was able to get the tablesorter to work w/ the standard apex component pageblocktable. Again, with jquery, the solution is basically the following:
1. Import your library as a static resource
2. Reference your resource in your vf page
3. Bind your jquery function and your component
So, applying the parts to my poc, I have a page that looks like this:
*******
<apex:page standardController="Opportunity" tabStyle="Opportunity" extensions="myext" id="thepage">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"/>
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"/>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="all" />
<apex:includeScript value="{!URLFOR($Resource.tablesorter, 'jquery.tablesorter.min.js')}"/>
<script type="text/javascript">
$j = jQuery.noConflict();
$j(document).ready(function () {
$j("[id$=theaddrs]").tablesorter();
});
//some other unrelated js
</script>
<!-- some other visualforce stuff then the heart of the proof of concept: -->
<apex:pageBlock id="theaddrsblock">
<apex:pageBlockTable value="{!Addrs}" var="a" id="theaddrs" styleClass="tablesorter" headerClass="header">
<apex:column>
<apex:facet name="header">
<apex:outputText styleClass="header" value="{!$ObjectType.Address__c.Fields.Street__c.Label}" />
</apex:facet>
<apex:outputText value="{!a.Street__c}" />
</apex:column>
<!-- the other columns, closing tags, and that's it -->
******
There is nothing to share about the controller because the sorting is being done w/out a callback to Salesforce.
The sections highlighted in yellow show how little is needed to modify your standard pageblocktable into a sortable table. Not much, right?
I suggest looking at the documentation or online discussions about optional parameters that can be specified in the tablesorter library but if you just have a few fields in a table that you need to sort, the tool will do a great job of figuring out the data magically. It's really awesome.
Now, this is only a proof of concept and so there is at least one issue resolve: the icons to indicate sort direction are displaying on top of the column labels. Should be able to modify the css to offset the icons. Worst case, we just remove the styleClass attribute on the outputtext of the column facet. Anyway, if you don't have to send it back to the controller for some logic or because the dataset is too large, just use the plugin to sort!