Angular Datatable Set Searchable False

I am trying to disable search on a specific column. Im using this server side angular.

https://l-lin.imtqy.com/angular-datatables

usually in jquery i can just:

 columns:[{data:"foo", name:"foo", searchable:false}]

I tried using:

   $scope.dtOptions = DTOptionsBuilder.newOptions()
            .withOption('ajax', {
                url: apiRoot + 'merchant-list'
            })
            .withDataProp('data')
            .withOption('serverSide', true)
            .withOption('order', [0, 'asc'])

  $scope.dtColumns = [
            DTColumnBuilder.newColumn('name', 'Name'),
            DTColumnBuilder.newColumn('type', 'Type'),
            DTColumnBuilder.newColumn('username', 'Username'),
 ]

 $scope.dtColumnDefs = [
            DTColumnDefBuilder.newColumnDef(0),
            DTColumnDefBuilder.newColumnDef(1).withOption('searchable', false),
            DTColumnDefBuilder.newColumnDef(2).withOption('searchable', false)
        ]

seems to work, but the columnDef position is incorrect. when I add newColumnDef (1) for the search to false, the column that should not be the search should be the second, but it seems to disable the first column.

Is there a way to disable the search for a specific column and order it?

thanks

Edit: I tried "ordering", false and notvisible works on columnDef 0. It seems that only searchability does not work.

+4
source share
2 answers

DTColumnBuilder DTColumnDefBuilder :

$scope.dtColumns = [
   DTColumnBuilder.newColumn('name', 'Name').withOption('searchable', false)
   ...
]

http://plnkr.co/edit/OOikiBKdLE8R1UEXLyMH?p=preview

$scope.dtColumnDefs = [
   DTColumnDefBuilder.newColumnDef('name', 'Name').withOption('searchable', false)
];
+5
$scope.dtOptions = {searching:false}

angular.

+1

Source: https://habr.com/ru/post/1608640/


All Articles