DataTable: Remove all horizontal borders

妖精的绣舞 提交于 2020-01-03 18:01:08

问题


How do I remove all the horizontal borders to just the even/odd shading?

https://datatables.net/examples/styling/stripe.html

This doesn't work.

table.dataTable.row-border tbody th, 
table.dataTable.row-border tbody td, 
table.dataTable.display tbody th, 
table.dataTable.display tbody td {
  border: none;
}

I would also like to remove the top and bottom black borders. This doesn't seem to have any effect.

table.dataTable thead th {
  border-bottom: 0;
  border-style: none;
}
table.dataTable tfoot th {
  border-top: 0;
  border-style: none;
}
table.dataTable .no-footer {
  border-bottom: 0;
}

回答1:


You can use the following code to remove all the horizontal borders to just the even/odd shading:

datatable(mtcars[1:3,1:3], class = 'stripe')




回答2:


You can remove the top border and the bottom border like this:

datatable(head(iris), 
          options=list(headerCallback = JS(
            "function( thead, data, start, end, display ) {
            $(thead).closest('thead').find('th').each(function(){
              $(this).css('color', 'red').css('border','none');
            });
            }"
            ),
            initComplete = JS(
            "function(settings) {
            var table = settings.oInstance.api(); 
            $(table.table().node()).removeClass('no-footer');
            }"))) 


来源:https://stackoverflow.com/questions/52248958/datatable-remove-all-horizontal-borders

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