How to get filtered data without data of hidden columns

How to get filtered data without data of hidden columns

OenselOensel Posts: 19Questions: 4Answers: 1

Is there a simple way to get all displayed data (including the other pages) ?

That's how I get all filtered data:

   table.rows( { filter: 'applied' } ).data()

But the information of hidden columns is included and I don't want it.

I also need to get all headers title but only the visible, not the hidden ones.
Any ideas ?

Replies

  • OenselOensel Posts: 19Questions: 4Answers: 1
    edited March 2015

    I solved the problem:

        var coulmnsVisible = tableApi.columns().visible();
        var columns = [];   
        var data = [];
    
        // Write all visible columns title to 'columns'
        $.each(tableApi.columns().header(),function(index)
        {
            if(coulmnsVisible [index])
            {
                columns.push($(this).text());
            }
        });
    
        // write all visible cells text to 'data'
        $.each(tableApi.rows( { filter: 'applied' } ).data(), function(rowIndex)
        {
            var columnIndex = 0;
            var cells = [];
            $.each(this, function(key,value)
            {
                if(coulmnsVisible [columnIndex++])
                {
                    cells .push(value);
                }
            });
            data.push(cells .join('~~'));
        });
    
This discussion has been closed.