I am using a apex:pageBlockTable with apex:columns on VF page. Is there any tag I can ad to have sortable columns. Note: I would like the column sorting to be in - memory rather than hitting the server again.

  • I think you can do it only with building some custom sort function. you can use JS or JQuery to do it if you dont want to do the server call. There are many open source examples on web for this. One of them is blogforce9.blogspot.in/2012/08/… – logontokartik Mar 26 '13 at 19:58

While I understand the desire to stick with pure VF, for column sorting and other advanced datagrids features you have to branch out to a Javascript framework.

I've personally used the following datagrid plugins, even some with in-line editing.

http://www.datatables.net/ - Requires jQuery, and can ajax load the data. While you can go to great lengths to rewrite parts of the plugin to utilize the ajax proxy I find it much simpler to build out a simple visualforce page returning json data for the grid. The downside to this one is the rather arcane syntax used to configure the datatable. Definitely a swiss-army-tool-gone-wild.

http://demos.kendoui.com/web/grid/editing-custom.html - Kendo isn't free but it's amongst the best data grids out there. easy to configure with a fallback option of always contacting support.

http://docs.sencha.com/ext-js/4-2/extjs-build/examples/build/KitchenSink/ext-theme-neptune/#array-grid - Ext.js from Scencha is also not free, and it looks a little 200&late to me, but it is a well done data grid.

Lastly, and honestly this is my personal recommendation though the learning curve is quite steep, http://angular-ui.github.com/ng-grid/ This one requires not only jQuery, but also Angular.js Angular is a relative sleeper-cell amongst the JS frameworks and works radically differently than anything else I've ever seen. That said, it's by far the most powerful, most concise, and most semantic of all these data grids. In the Angular world (ng for short) you develop "directives" which act as either Elements, Attributes, Classes or Comments to standard HTML markup. In other words you can develop a directive called dataGrid, specify that it's an Element directive and then utilize the brand new-materialized-from-your-js-code <data-grid> </data-grid> tags in your visual force pages. Neat.


Unfortunately as of today there isn't any native support for sorting with the apex:pageBlockTable, you've got to roll your own. This can usually be done pretty easily with an javascript ui framework (i.e. jQuery UI or YUI).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.