datatables column properties
datatables column properties
我使用的是DataTables表组件,其中一列有很长的数据行。目前,这些数据基本上是通过将列宽扩展到适合数据所需的宽度,从而添加水平滚动条来显示的。
我想限制列像这样扩展,并限制文本换行。
这就是当前代码看起来像的样子
var dt = $(document).ready(function() {
var dt =$('#feedback-data-table').DataTable( {
ajax: {
url: "http://127.0.0.1:7101/Oats/rest/v1/testidmap?onlyData=true&limit=999",
dataSrc: "items"
},
columns: [
{ title: "Test Name", data: "TestName" },
{ title: "User Activity Info (~ separated)", data: "Useractivityinfo"}
]
} );
} );
请告知如何实现这一目标。像这样添加宽度:"100px"是行不通的。
解决方案
您可以对包含长文本的列使用CSS规则word-break: break-all;
,该列在任何字符之间都没有任何空格来分隔单词。
JavaScript
$(document).ready(function (){
var table = $('#example').DataTable({
columnDefs: [
{ targets: 5, className: "word-break-all" }
]
});
});
CSS:
.word-break-all {
word-break:break-all;
}
有关详细信息,请参见word-break
。
演示
有关代码和演示,请参阅此jsFiddle。
您能使用以下CSS并查看吗?
table {
table-layout:fixed;
}
th {
word-rap: break-word
}
相关文章:
- javascript中对象构造函数中的var属性与this.properties
- 为什么是文档.旧版应用程序中的DOM-object.properties为null
- 定义this.properties或objectName.properties的javascript JSON对象
- How to declare a Map containing certain properties with flow
- zoomToCategory on amchart column chart
- 通过使用jQuery对元素重新排序来模拟CSS Column垂直内容流
- javascript对象显示为null,但object.properties返回数据
- 如何在gsp页面上从javascript调用messages.properties(参数化)值
- 如何从catalina.properties获取值到jsp
- Highcharts column Point Click
- 将变量从控制器传递到Devexpress GridView Column EndCallBack JS
- 在spring-boot中使用javascript在application.properties文件中获取值
- Javascript属性访问速度:var.properties与var[“属性”]的区别
- 如何在html表Column中包含标记
- 使用 Ext.create 在 ExtJS 4 GridPanel Column 中渲染动态组件
- 在另一场胜利中获取Titanium.App.Properties或使其在全球范围内可用
- AngularJS + NG-Grid 将 row.column.field 传递到 ng-click 事件中
- Javascript max() for array column
- jQuery DataTables fnRender Increment Column
- datatables column properties