jQuery DataTables 最大列宽
我在 .NET Web 应用程序中使用 jQuery DataTables,但如何设置一个特定列的最大宽度,所有其他列应自动调整大小(就像它们现在在我的表中一样)
编辑
DataTables 自己正确地完成了它,问题是有一个很长的单词没有空格导致了问题
I'm using jQuery DataTables in my .NET web application but how do I set a max width for one specific column, all the other columns should be auto sized (like they are now in my table)
EDIT
The DataTables did it correctly by itself, the problem was there was a very long word without spaces that cause the problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你的问题似乎与 CSS 更相关......
在 CSS 中使用 word-wrap 可以解决这个问题,因为 columnX 只需将其添加到你的 CSS 中即可。
根据您为列设置的宽度,它甚至会包装没有空格的单词。
请参阅:https://developer.mozilla.org/en/css/word-wrap
Your problem seems more CSS related ...
Using word-wrap in CSS would fix that issue, for columnX just add this to your CSS.
It would wrap even words without spaces based on your set width for the column.
See: https://developer.mozilla.org/en/css/word-wrap
我同意上述使用自动换行的解决方案 - 它效果很好。但是,对于包含大量数据的列,我还遇到了更多问题。我还执行了以下操作以使其完全正常工作:
我在
数据表
的列宽度方面遇到了许多问题。对我来说,神奇的解决方法是包括这行This
css
comes with the another整体css
of the table。例如,如果您已按如下方式声明datatables
:那么神奇的
css
行将位于类Loadtable
中。I agree with the above solution of using the
word wrap
- it works great. However, I had further issues with columns with large amounts of data in. I also did the following to get it fully working:I have had numerous issues with the column widths of
datatables
. The magic fix for me was including the lineThis
css
goes with the overallcss
of the table. For example, if you have declared thedatatables
like the following:Then the magic
css
line would go in the classLoadtable
.我通过修改内容(如果太长)并在工具提示中显示全文来控制列宽。
使用 span 元素,您也可以直接控制长度。
I am controlling the column width by modifying the contents if too long and displaying the full text in a tooltip.
Using the span element, you could control length directly as well.
使用此链接可以轻松
获取更多信息。
(如何设置特定列的最大宽度在 jQuery DataTables 中)!
It can be easy with use of
Refer this link for more information.
(How to set max-width for particular column in jQuery DataTables)!