在jquery数据表中,我可以通过
禁用特定的列排序Error: The operation is insecure.
Jf/l.url@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:44:436
h@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:104:180
ef/this.$get</</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:107:221
hf/this.$get</m.prototype.$eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:134:393
hf/this.$get</m.prototype.$digest@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:131:418
hf/this.$get</m.prototype.$apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:135:158
ef/this.$get</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:106:46
Gf/c@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:35:70
e/<()angular.min.js (line 108)
Ye/this.$get</<()angular.min.js (line 80)
hf/this.$get</m.prototype.$digest()angular.min.js (line 131)
hf/this.$get</m.prototype.$apply()angular.min.js (line 135)
ef/this.$get</<()angular.min.js (line 106)
Gf/c()angular.min.js (line 35)
任何人都知道如何在角度JS中做到这一点?
"aoColumnDefs": [{
'bSortable': false,
'aTargets': [0, 7]
}]
此代码隐藏了我的搜索栏,但无法隐藏我的第一列和第四列的排序功能?
答案 0 :(得分:19)
角度数据表等效于
aoColumnDefs: [{ bSortable: false, aTargets: [0, 4] }]
是
$scope.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).notSortable(),
DTColumnDefBuilder.newColumnDef(4).notSortable()
];
...
<table class="custom-table" dt-column-defs="dtColumnDefs" datatable="ng" dt-options="dtOptions" id="contacts-list-table"></table>
您必须在控制器中加入DTColumnDefBuilder
:
myApp.controller("ListCtr", ['DTOptionsBuilder', 'DTColumnDefBuilder',
function(DTOptionsBuilder, DTColumnDefBuilder) {
$scope.dtOptions = DTOptionsBuilder.newOptions().withDOM('C<"clear">lfrtip');
$scope.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).notSortable(),
DTColumnDefBuilder.newColumnDef(4).notSortable()
];
}
])
请参阅 http://l-lin.github.io/angular-datatables/archives/#!/api 。
答案 1 :(得分:0)
我已经尝试了所有可能的解决方案来禁用排序,但唯一对我有用的是:dtOptions
。 article
我的vm.dtOptions = {
dom: '<"top"f>rt<"bottom"<"left"<"length"l>><"right"<"info"i><"pagination"p>>>',
pagingType: 'simple',
autoWidth: false,
responsive: true,
order: false, // This fixed the issue
columnDefs : [{
targets: [0, 1, 2, 3, 4, 5, 6, 7], // column or columns numbers
orderable: false, // This was not working
filterable: false,
sortable : false
},
{
// Target the actions column
targets : 8,
responsivePriority: 1,
filterable : false,
sortable : false,
orderable: false
}
]
}
如下
{{1}}