DataTables / Responsive

Responsive extension for DataTables, providing support for complex tables on all device screen sizes
Other
148 stars 87 forks source link

responsive vs hidden columns #8

Closed alesnav closed 10 years ago

alesnav commented 10 years ago

Hello Allan,

I didn't see this nice plugin, so I will start using it :)

But I have a problem, I must hide some columns because those contain just codes/IDs and are not useful for users. When I enable responsive plugin, I can't hide these columns.

You can see this here (column name "Position" should be hidden): http://live.datatables.net/wasugivi/1

Thanks!

P.D.: sorting icons are not found when using default template in live.datatables.net: http://datatables.net/download/build/images/sort_both.png http://datatables.net/download/build/images/sort_asc.png http://datatables.net/download/build/images/sort_desc.png

DataTables commented 10 years ago

You can use the never class in the very latest (unreleased at this time) code. There is a discussion about it here: https://datatables.net/forums/discussion/23409

alesnav commented 10 years ago

Ok, then using classes and the nightly version of Responsive css and js:

http://live.datatables.net/wasugivi/2

You can see, column Position has class never and it is not shown, but you have the + image anyway. When you click on + button, nothing is displayed and you won't be able to click -.

Nice Allan, good work! :)

DataTables commented 10 years ago

Good point - thanks. I'll try to take a look at that later this week.

DataTables commented 10 years ago

Fixed with commit cea1178f324 and the test case is working now: http://live.datatables.net/wasugivi/2/edit .

Thanks!

alesnav commented 10 years ago

Yes, it does work now.

Thanks Allan!

cdaringe commented 9 years ago

I'm struggling to do this dynamically. The following adds the class, but the column still shows. I've tried triggering a draw(), which is actually counter productive. Tips?

$header = jQuery($dt.column('col1:name').header());
$header.addClass('never'); // confirmed, never is in tacked onto the th
DataTables commented 9 years ago

There isn't an option to dynamically add a class and have Responsive take that into account at the moment. Good suggestion though - I've added issue #21 for this feature.

cdaringe commented 9 years ago

hey @DataTables, idea. what if the api.columns(...).visibility(boolean) { ... } checks if responsive mode is enabled, and if so, applies 'never' to the header such that the column hiding logic behavior is consistent with non-responsive tables? is that a reasonable solution?

DataTables commented 9 years ago

Problem with that is that it would imply DataTables has to have knowledge of the plug-in, which it shouldn't. More of a problem is that Responsive actually uses column().visibility() itself.

Having said that, it isn't an insurmountable problem using that method, a listener could look for column-visibility.dt and if triggered externally, then the class could be added. That could be a neat solution - thanks for the suggestion.

bensonism commented 6 years ago

So is the current status that dynamic tables using responsive can't have hidden columns?

DataTables commented 6 years ago

No. Responsive 2 was rewritten not to use column().visibility(). If you are having a problem with this, please open a new discussion in the forum with a link to a test case showing the issue.