jQuery - 数据表排序后不保留列宽
我有一个 jQuery 数据表,我指定了列宽,如下所示:
"aoColumnDefs":[
{ "sWidth":"40%" },
{ "sWidth":"10%" },
{ "sWidth":"50%" } ]
我还指定了 CSS 样式,如:
td { position: relative, word-wrap: break-word; }
该表完全按照我想要的方式显示,长条目已被包装。但是,当我对第二列进行排序时(排序由后端服务器处理),第一列的一些值很长,但从未中断和换行。该表仅显示一列(由于值的最长长度超出了表宽度)。
如何让数据表遵守初始化的宽度并正确渲染?
I have a jQuery data-table which I specified the column width likes following:
"aoColumnDefs":[
{ "sWidth":"40%" },
{ "sWidth":"10%" },
{ "sWidth":"50%" } ]
I also specified the CSS style like:
td { position: relative, word-wrap: break-word; }
The table displays exactly as I wanted, long entries have been wrapped. However, when I sorted on the second column (the sorting is handled by the back-end server), some of the values of the first column are long but never broke and wrapped. The table showed only one column (due to the longest length of the value exceeded the table width).
How can I get the data-table obey the initialized width and render correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用该列中单元格的
sClass
属性来设置样式,转到此处 http://datatables .net/ref 并向下滚动 sClass 引用。(长类名只是为了让大家明白你的类将有什么CSS)
You can try using the
sClass
property of the cells in that column to style go here http://datatables.net/ref and scroll down the the sClass reference.(The long class name is just to get the point across as to what your class would have as css)