在 Angular JS 中如何禁用选定列的列排序功能 [英] In Angular JS how to disable column sort feature for selected columns

查看:22
本文介绍了在 Angular JS 中如何禁用选定列的列排序功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 jquery 数据表中,我可以禁用特定的列排序

In jquery data table I can disable specific column sort by

"aoColumnDefs": [{
                'bSortable': false,
                'aTargets': [0, 7]
            }]

有人知道如何在 Angular JS 中做到这一点吗?

Anyone know how to do this in angular JS?

<table class="custom-table" datatable="ng" dt-options="dtOptions" id="contacts-list-table">
</table>

myApp.controller("ListCtr", ['DTOptionsBuilder', function(DTOptionsBuilder) {
  $scope.dtOptions = DTOptionsBuilder.newOptions().withDOM('C<"clear">lfrtip') 
}])

这段代码隐藏了我的搜索栏,但无法隐藏我的第一列和第四列的排序功能?

this code hiding my search bar but not able to hide sort feature of my first and fourth column?

推荐答案

Angular-datatables 等价于

The angular-datatables equivalence to

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 :

You must include DTColumnDefBuilder in the controller :

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.

see http://l-lin.github.io/angular-datatables/archives/#!/api.

这篇关于在 Angular JS 中如何禁用选定列的列排序功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆