Filtered data from column

Filtered data from column

jmcshan1jmcshan1 Posts: 9Questions: 3Answers: 0
edited August 2015 in Free community support

I just wanted to put this little script out there in case others were looking for something similar. I needed to get only the displayed rows from the table after applying a filter. Here's the 5 line script to add this to the column API:

$.fn.dataTable.Api.register('column().filteredData()', function() {
    return this.table().settings()[0].aiDisplay
        .map(function(it) { 
            return this.data()[it];
        }, this);
});

Replies

  • jmcshan1jmcshan1 Posts: 9Questions: 3Answers: 0

    Similarly for filtering the data from the whole table:

    $.fn.dataTable.Api.register('filteredData()', function() {
        return this.settings()[0].aiDisplay
            .map(function(it) { 
                return this.data()[it];
            }, this);
    });
    
This discussion has been closed.