YADCF MULTI_SELECT与服务器端进行过滤 [英] YADCF multi_select filter with server side

查看:112
本文介绍了YADCF MULTI_SELECT与服务器端进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与AngularJS的工作,我有一个DataTable()在服务器端模式下工作,使用YADCF过滤器。
是否有可能使用 MULTI_SELECT 过滤器(蒙山选择或选择2),而服务器端的工作吗?我可以手动介绍搜索的参数?在这种情况下,我想使用过滤器在列#6(国家体制),这意味着下面的一个进程的国家。

Working with AngularJS, I have a DataTable() working in serverSide mode, using the YADCF filters. Is it possible to use the multi_select filter (whith chosen or select2) while working on ServerSide? Can I manually introduce the parameters of search? In this case I want to use that filter on the column #6 ("estado") that means "The state" of a proccess.

从code中的 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,所以这是不可能选择一个或多个国家...

When I filter the first time, because its server-side it only have access to the proccess with that state, so it's impossible to chose one or more states...

推荐答案

在这情况下,要触发yadcf筛选您更好地使用yadcf API

In case that you want to trigger yadcf filter you better use 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);


在您要筛选多个值的情况下,您可以添加更多的阵列,像这样


In case that you want to filter multiple values, you can add more to the array, like this

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

阅读更多有关 exFilterColumn API

请注意,第三真正参数应该用来过滤出已经载入上午AJAX源数据表时(无文档对于尚未)

note that the third true argument should be used when filtering am ajax sourced datatable that was already loaded (no docs for that yet)

这篇关于YADCF MULTI_SELECT与服务器端进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆