2015-01-07 130 views
0

使用AngularJS,我有一個DataTable()工作在serverSide模式,使用YADCF過濾器。 在ServerSide上工作時是否可以使用multi_select篩選器(通過select或select2)?我可以手動引入搜索參數嗎?在這種情況下,我希望在第6列(「estado」)上使用該過濾器,這意味着進程的「狀態」。與服務器端YADCF multi_select過濾器

的代碼從myApp.controller

var table = $('#tbl').DataTable({ 
     stateSave: true, 
     stateDuration: -1, 
     //sRowSelect: "multi", 
     language: sharedProperties.getLanguageDatatable(), 
     dom: '<"toolbar">T<"clear">lfrtip',    
     "columnDefs": [ 
      { "data": "processosId", "targets": 0, "visible": false, "searchable": false }, 
      { "data": "utilizadoresId", "targets": 1, "visible": false, "searchable": false }, 
      { "data": "entidadesId", "targets": 2, "visible": false, "searchable": false }, 
      { "data": "numero", "targets": 3 }, 
      { "data": "nomeEntidade", "targets": 4, "visible":entidadeCol }, 
      { "data": "nomeUtilizador", "targets": 5, "visible":utilizadorCol }, 
      { "data": "estado", "targets": 6 },     
     ], 
     serverSide: true, 
     ajax: { 
      "url": urlProcessos, 
      "error": function (reason) { 
       if (reason.status == 401) { // Not Authorized 
        self.location = '#/logout'; 
       } 
      } 
     }, 
}); 

    yadcf.init(table, 
    [ 
     { column_number: 3, filter_type: 'text', filter_default_label: "" }, 
     { column_number: 4, filter_type: 'text', filter_default_label: "" }, 
     { column_number: 5, filter_type: 'text', filter_default_label: "" }, 
     { column_number: 6, filter_type: 'multi_select', filter_default_label: "", select_type:'chosen' },    
    ]); 

    $scope.newProcess = function() {    
     table.columns(6).search('Novo').draw(); 

    } 

    $scope.openProcess = function() { 
     table.columns(6).search('Aberto').draw(); 
    } 

當我篩選的第一次,因爲它的服務器端只訪問與狀態proccess,所以這是不可能選擇一個或多個狀態..

回答

0

如果要觸發yadcf過濾您更好地使用yadcf API

我建議你更換

table.columns(6).search('Novo').draw(); 

table.columns(6).search('Aberto').draw(); 

與要過濾多個值這樣的事情

yadcf.exFilterColumn(oTable, [[0, ['Novo']]], true); 

yadcf.exFilterColumn(oTable, [[0, ['Aberto']]], true); 

在情況下,您可以添加更多的陣列,像這樣

yadcf.exFilterColumn(oTable, [[0, ['Novo', 'Aberto']]], true); 

閱讀更多關於exFilterColumn api

注意第三個true參數應使用過濾一個已經裝(無文檔對於尚未)上午AJAX源數據表時

+0

只要有更新的WebAPI到在該字段中接收多個值。謝謝 – NunoRibeiro

+0

你可以看看這個[問題](http://stackoverflow.com/questions/27862386/how-to-stop-yadcf-filters-in-datatables-to-mess-with-the-headers-cell寬度)? – NunoRibeiro