Data_table sorting function

edited February 2011 in News & Announcements
This is a response to a @jmlweb's twitter question regarding implementing sorting with the Data_table class.

The Data_table class doesn't provide any built in sorting capabilities per se, other then pointing to a javascript function, and relies on the user to implement that functionality. In the FUEL admin, we use a function called sortList which can be found in the fuel/modules/fuel/assets/js/controller/BaseFuelController.js file. This function uses AJAX to submit 2 hidden fields for the name of the column and the sorting direction of "asc" or "desc". The fuel/modules/fuel/controllers/module.php controller handles the processing of the request with the items() method (note on line 196 or so where it tests to see if it is an ajax request or not). The AJAX returned is the new table HTML to replace.

The reason we didn't use an entire Javascript based table sorter is because we felt that this method didn't require a lot of javascript sorting overhead required for big data sets and it also made sorting with pagination a little easier.
Sign In or Register to comment.