我正在使用带有服务器端处理的 Angular 数据表(https://github.com/l-lin/angular-datatables),如果我没有添加列过滤器,一切正常但是一旦我添加了withColumnFilter
选项然后搜索,分页和每页记录停止工作。
这是我的 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。我为此附上了截图: