2015-12-04 163 views
3

我正在使用Angular datatables(https://github.com/l-lin/angular-datatables)进行服务器端处理,如果我没有添加列过滤器,一切正常,但一旦我添加withColumnFilter选项,然后搜索,分页和每页记录停止工作。columnFilter插件不适用于Angular DataTables服务器端处理

这里是我的HTML部分:

<div class="container-fluid"> 
<table datatable="" dt-options="vm.dtOptions" dt-columns="vm.dtColumns" class="row-border hover"> 
<tfoot> 
<tr> 
    <th>First Name</th> 
    <th>Last Name</th> 
    <th>Email ID</th> 
    <th>Phone Number</th> 
</tr> 
</tfoot> 
</table> 
</div> 

JS部分:

(function() { 
'use strict'; 

angular 
.module('com.module.users') 
.controller('UserCtrl', UserCtrl); 

UserCtrl.$inject = ['$state', '$rootScope', 'ENV', 'DTOptionsBuilder', 'DTColumnBuilder']; 
function UserCtrl($state, $rootScope, ENV, DTOptionsBuilder, DTColumnBuilder) { 
var vm = this; 

vm.currentPageState = $state.current.stateDesc; 

vm.dtOptions = DTOptionsBuilder.newOptions() 
    .withOption('ajax', { 
    url: ENV.apiUrl + vm.currentPageState.rUrl + '/users', 
    type: 'POST', 
    headers: { 
     Authorization: 'Bearer ' + $rootScope.globals.currentAdmin.token 
    } 
    }) 
    .withDataProp('data') 
    .withOption('processing', true) 
    .withOption('serverSide', true) 
    .withPaginationType('full_numbers') 
    .withBootstrap() 
    .withColumnFilter({ 
    aoColumns: [{ 
     type: 'text', 
     bRegex: true, 
     bSmart: true 
    }, { 
     type: 'text', 
     bRegex: true, 
     bSmart: true 
    }, { 
     type: 'text', 
     bRegex: true, 
     bSmart: true 
    }, { 
     type: 'text', 
     bRegex: true, 
     bSmart: true 
    }] 
    }); 

vm.dtColumns = [ 
    DTColumnBuilder.newColumn('firstName').withTitle('First name'), 
    DTColumnBuilder.newColumn('lastName').withTitle('Last name'), 
    DTColumnBuilder.newColumn('email').withTitle('Email ID'), 
    DTColumnBuilder.newColumn('phone').withTitle('Phone Number') 
]; 
} 

})(); 

调试我发现了什么是AJAX URL得到改变DOM URL后。我附上截图此:

Click here to see the image

+1

请提供您的代码的详细信息。请参阅[如何提出一个好问题](http://stackoverflow.com/help/how-to-ask)和[如何创建最小,完整和可验证示例](http://stackoverflow.com/help/mcve) – Tristan

+0

...请不要将问题标为紧急。对你来说可能是迫切的,但是对于现在和下一年的读者来说,这并不是紧急的。 – halfer

+0

请参阅https://github.com/l-lin/angular-datatables/issues/475。 –

回答

0

它的工作使用,而不是AJAX选项withFnServerData。

相关问题