JQuery Datatables columns overflow

Deadly 提交于 2019-12-25 06:59:26

问题


I have problem with my datatable: it has to have a specific width, but also I want to display all its columns. The whole issue looks like this:



I found solutions Datatables Width Overflow For A Lot Of Columns and JQuery Datatables overflow, but I would rather use word breaking then have a scrollbar in my table.

So, I found another solution jQuery DataTable overflow and text-wrapping issues according to which i had to set:

  table.display { table-layout:fixed; }
  th, td { word-wrap:break-word; overflow:hidden; text-overflow: ellipsis; }

However, with this I had a problem with column width; all columns have same width and option "bAutoWidth: true" is ignored:

For example, there is an empty horizontal space in Price column, or after icons at last column. Moreover word-broken headers (th) seem very ugly, and it would look better if Code, Count, Price and Place columns were at their minimum size (their width matched width of header text).

I would like to specify (somehow) preferred width for each column, or after how many letters it should wrap. I found breakCellText plugin in this post jQuery DataTable overflow and text-wrapping issues. Nevertheless, this plugin is not working with my datatables 1.9.4.


回答1:


I had the same problem. Here is my solution:

.dt-index {
    column-width: auto !important;
}

Please use this style for your table.

I hope that will be your solution.

Greetz Vegeta_77



来源:https://stackoverflow.com/questions/21688919/jquery-datatables-columns-overflow

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