Skip to content

Commit

Permalink
Improve performance significantly
Browse files Browse the repository at this point in the history
Unfortunately the fix for the preformance was to stop re-creating the
Datatables API object and instead use a private API, so this might break
in the future.
  • Loading branch information
cristoper committed Jan 11, 2016
1 parent 0eceece commit e614919
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions kiva_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ajax: fetchData,
columnDefs: [{
targets: "_all",
data: getData
render: getData
}]
};

Expand All @@ -42,9 +42,15 @@
* @returns {String} - The text (HTML) to display for the requested cell
* @see http://datatables.net/reference/option/columns.data
*/
function getData(row, type, set, meta) {
var api = new $.fn.dataTable.Api(meta.settings);
var colName = api.table().node().columns[meta.col];
function getData(data, type, row, meta) {
// This is too slow!:
//var api = new $.fn.dataTable.Api(meta.settings);
//var table = api.table().node()

/* So instead we must unfortunately rely on the private API of the
* settings object: */
var table = meta.settings.nTable;
var colName = table.columns[meta.col];
var field = row[colName];

if (type == "sort" || type == "type") {
Expand Down

0 comments on commit e614919

Please sign in to comment.