Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work when datatable contains hidden columns #25

Closed
mklerx opened this issue Dec 19, 2013 · 2 comments
Closed

Does not work when datatable contains hidden columns #25

mklerx opened this issue Dec 19, 2013 · 2 comments

Comments

@mklerx
Copy link

mklerx commented Dec 19, 2013

Let me start to say I really appreciate this project.
I have one problem that I am trying to fix, but I think this will affect other users as well.

I have a hidden column in my column definitions (bVisible: false). The first one actually (column ID 0). Datatables does not create a for a hidden column. But your logic to detect which column has the expand button uses a jQuery call:

var headerElements = $('thead th', this.tableElement);

Which does not take the hidden columns into account.

This can be solved by changing this line to:

var headerElements = this.tableElement.fnSettings().aoColumns;

and an

element = element.nTh;

after the _each on line 164. This fixes the incorrect expand column.

But then the detection of which columns should be hidden and shown still fails and the column to the right of the one that should be hidden is hidden (because of the difference between th:eq(0) and column with ID 0.

Do you agree it would be best to use fnSettings().aoColumns instead of the (incomplete) $('th') in your code?

@comanche
Copy link
Owner

Yes, it is better to use fnSettings().aoColumns. It should be fixed now. Make sure you define data-class="expand" on a non-hidden column th.

@mklerx
Copy link
Author

mklerx commented Dec 23, 2013

Works great, thanks oa lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants