2015-12-04 95 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。

相關問題