angularjs - Angularjs Datatable 从列可见性中排除列
问题描述
我正在研究数据表列的可见性,但我不希望所有表列都显示在可见性下拉列表中,只需要显示几个
我试过 DTColumnDefBuilder.newColumnDef(0).withTitle('Name').notVisble() 但它删除了列并没有解决它
html代码
<table class="table table-striped dataTable no-footer dtr-inline" datatable="ng" dt-options="dataDtOptions" dt-instance="dataDtInstance" width="100%" dt-columns="dataDtColumns" dt-column-defs="dataDtColumnDefs">
<thead>
<tr>
<th>column1</th>
<th>column2</th>
<th>column3</th>
<th>column4</th>
<th>column5</th>
<th>column6</th>
</tr>
</thead>
<tbody>
<tr style="cursor:pointer" ng-repeat="data in datas" >
<td>{{data[0]}}</td>
<td>{{data[1]}}</td>
<td>{{data[2]}}</td>
<td>{{data[3]}}</td>
<td>{{data[5]}}</td>
<td>{{data[6]}}</td>
</tr>
</tbody>
</table>
angulajs 代码
$scope.dataDtOptions = DTOptionsBuilder.newOptions()
.withDOM("<'row'<'col-sm-5'l><'col-sm-2 width-200 pull-right'B><'col-sm-5 pull-right'f>>" +"<'row'<'col-md-12't>>" +"<'row'<'col-sm-5'i><'col-sm-7'p>>")
.withPaginationType('full_numbers')
.withButtons([
'colvis',
{
extend: 'collection',
text: 'Export',
buttons: [
'csv',
'pdf'
]
}
]);
$scope.dataDtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).withTitle('column1'),
DTColumnDefBuilder.newColumnDef(1).withTitle('column2'),
DTColumnDefBuilder.newColumnDef(2).withTitle('column3'),
DTColumnDefBuilder.newColumnDef(3).withTitle('column4'),
DTColumnDefBuilder.newColumnDef(4).withTitle('column5'),
DTColumnDefBuilder.newColumnDef(5).withTitle('column6'),
]
所以我不希望列可见性下拉列表中的第一列和最后一列
解决方案
You can do the following:
DTColumnBuilder.newColumnDef(0).withClass('hidden')
And in CSS if you don't already have bootstrap installed
.hidden { display: none; }
推荐阅读
- java - 自定义键盘的候选视图弄乱了 WhatsApp 和其他应用程序布局
- java - 多播对等方未从 Java 中的特定对等方接收数据报包
- javascript - 如何存储和使用 DOM 节点
- excel - 我可以使用 Vlookup 来获得匹配,然后再往前走吗
- javascript - 创建数组的更好方法?
- mysql - Go gorm 预加载多对多
- reactjs - 动作必须是普通对象,我该如何改进我的动作?
- python - Python can't find "__main__" module
- html - 如何在输入字段reactjs中设置输入字母数字值格式?
- python - 如何使用 Python 从 Google Drive API 初始化 drive_service 对象?