JS Datatables - Toggle Show/Hide with responsive auto showing other columns

邮差的信 提交于 2020-01-16 07:37:52

问题


I have a responsive Datatable that also has the Show/Hide columns feature enabled. I've noticed that whenever I hide a column using the show/hide buttons, a new column will automatically appear in order to fill the width of the page.

Is there a way to disable this so that if I toggle a column to hide, another column does not try and fill its place, but the existing columns will just fit the width of the page?

A test case of my current issue can be found here: http://live.datatables.net/huruwaro/1/edit

Thanks for your time!


回答1:


Try to redraw the table after clicking the button

$('#myTable1').DataTable().clear().draw();

or

$('#myTable1').DataTable().columns.adjust().draw(); 

or

$('#myTable1').DataTable().columns.adjust().draw(false); 


来源:https://stackoverflow.com/questions/59670605/js-datatables-toggle-show-hide-with-responsive-auto-showing-other-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!