Giter Club home page Giter Club logo

datatables-hide-empty-columns's People

Contributors

alexeykosov avatar jhyland87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

datatables-hide-empty-columns's Issues

performance issues on big tables

There is significant lag on a tables with 5000+ rows and 30 or so columns. So I propose couple of optimisations.
First, break loop on first non empty column found as there is no point to check rest of columns as result is already predetermined:
for (var i = info.start; i < info.end; i++)
 if (_isEmpty(data[i]))
 empty++
 else
 break;

Second, which brings most benefit - is to disable "redraw" upon each column setting visible or not:
if (empty === (info.end - info.start)) { api.column(this.index()).visible(false, false) } else { api.column(this.index()).visible(true, false) }

after calling _checkPage() do api.draw();

filter issue

There is another interesting issue with filtering and paging:

var data = this.data().toArray() - gets ALL columns (for example 239).

But when filtering is done, page.info is set to:
{"page":0,"pages":1,"start":0,"end":8,"length":20,"recordsTotal":239,"recordsDisplay":8,"serverSide":false}

Idea is that
// Only loop through the rows that are visible, using the page info for (var i = info.start; i < info.end; i++) { if ($.trim(data[i]) === '') empty++ }
loops just via FIRST 8 rows, but NOT the ones which are actually SHOWN on the screen.

columns on last page are not hidden

Hey, you have made same bug I had ;)

Here is demo - "Age" on last page remains unhidden because of:

if (empty === info.length) api.column(this.index()).visible(false) else api.column(this.index()).visible(true)

where info.length doesn't mean that there will be same amount of rows as page could have.
Thats why I have used (info.end - info.start)

(...).every is not a function

Hello,

When dataTables runs the hideEmptyColums.js the code keeps breaking at line 257: Uncaught TypeError: api.columns(...).every is not a function. Anything I can do I my end?

line 145: perPage = _cfgItem( 'perPage'), //is undefined with no second parameter.

Thanks,

Mark

npm

Hello,
As this project seems a little bit dead, but I am using this plugin daily - I am going register it to bower repository (my fork).

Datatables stateSaving "conflicts"

If stateSave is enabled when page is refreshed and different data is shown in table, it doesn't unhide previously hidden columns. E.g.

There are columns A, B and C. C column is empty.

New query is performed page is refreshed and column C now longer empty, however it remains hidden.

Hide only if not already hidden

Hiya,
I found that if I had already hidden a column with other logic, then the plugin made them visible.

So to ignore the columns I had already hidden, I modified the following

	if( api.column( this.index()  ).visible() === true) {
            api.column( this.index() ).visible( isVis )
			}

Might be useful for someone else if it was set up as an option

Does perPage work with AJAX data?

Just found this and I've been trying to make this work with my table that get its data using AJAX.
It appears to hide the columns when they're empty but the columns don't come back if I navigate back to a page where they're not empty.
For the columns to show again I have to refresh the page.

I've copied the bit from the example for perPage the only difference seems to be that I'm loading the data with AJAX instead of it already being on the page.

Is there something I could have missed?

Here's how I've created the table if it's any help:

    $(document).ready(function () {
        var oTable = $('#e-table').dataTable({
            columns: [
                {title: "Name"},
                {title: "Serial Number"},
                // Some more columns generated by PHP
            ],
            serverSide: true,
            "bInfo": false,
            "bLengthChange": false,
            "pageLength": 15,
            "oLanguage": {
            "sZeroRecords": "Nothing to display",
                    "sSearch": ""
            },
            hideEmptyCols: {
                columns: <?php echo $columnsToHide; ?>,
                perPage: true
            },
            "ajax": '/ajax_table/'
        });
    });

The data returned from /ajax_table/ is just as the dataTables spec says it should be.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.