简体   繁体   中英

JQuery Datatables columns overflow

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM