From 1b4688cdf3537e4a20fa573cc27bfda5dacb9236 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Sun, 19 May 2013 09:54:46 +0100 Subject: [PATCH] API: Consistency of data return for columns().data() - The columns().data() method was flattening the returned array. While possibly okay on its own, that doesn't match the behaviour of how rows().data() works, where each row is an entry in the array, rather than the array being flattened. As such I've changed columns().data() to work work in the say way, for each column you select, you get an entry in the api instance - an array with the data for the that column. - To allow for hte fact that some may want to work with the flattened data, I've added a `flatten()` method to the instance base, which is basically a shortcut call to `reduce`. --- media/src/api/api.base.js | 8 ++++++++ media/src/api/api.cells.js | 4 ++-- media/src/api/api.columns.js | 2 +- media/src/api/api.rows.js | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/media/src/api/api.base.js b/media/src/api/api.base.js index 7aed733f..08b0a687 100644 --- a/media/src/api/api.base.js +++ b/media/src/api/api.base.js @@ -307,6 +307,14 @@ _Api.prototype = /** @lends DataTables.Api */{ }, + flatten: function () + { + return this.reduce( function ( a, b ) { + return a.concat( b ); + } ); + }, + + indexOf: _arrayProto.indexOf || function (obj, start) { for ( var i=(start || 0), ien=this.length ; i