diff --git a/media/src/DataTables.js b/media/src/DataTables.js index 23e09d4e..80eca512 100644 --- a/media/src/DataTables.js +++ b/media/src/DataTables.js @@ -113,11 +113,11 @@ require('api.draw.js'); require('api.page.js'); require('api.ajax.js'); - require('api.order.js'); require('api._selectors.js'); require('api.rows.js'); require('api.row.js'); require('api.columns.js'); + require('api.order.js'); require('api.search.js'); require('api.static.js'); require('api.core.js'); diff --git a/media/src/api/api.order.js b/media/src/api/api.order.js index 9eedd929..de1230ed 100644 --- a/media/src/api/api.order.js +++ b/media/src/api/api.order.js @@ -77,5 +77,22 @@ _Api.register( 'order.listener()', function ( node, column, callback ) { } ); +// Order by the selected column(s) +_Api.register( 'columns().order()', function ( dir ) { + var that = this; + + return this.iterator( 'table', function ( settings, i ) { + var sort = []; + + $.each( that[i], function (j, col) { + sort.push( [ col, dir ] ); + } ); + + settings.aaSorting = sort; + } ); +} ); + + + }());