YADCF,列可见性与filter_container_id无法正常工作

时间:2016-08-02 08:46:47

标签: jquery datatable yadcf

我对Datatables,YADCF和Button Colvis有点问题: 我不能在同一个表中使用属性visible:false,filter_container_id和yadcf。 yadcf插件崩溃而不显示任何内容。这是我的数据表初始化的清理版本:

datatable = $('#Datatable').DataTable({
    serverSide:true,
    processing:true,
    ajax: {
        url: '/app/object/liste',
        type: "POST"
    },
    columns: [
        {data:"pc_id", width:"90px"},
        {data:"pc_statut", visible:false, width:"90px"},
        {data:"reference_dossier", width:"90px"}],
    buttons: [{
        extend: 'colvis',
        text: 'Colonnes',
        collectionLayout: 'fixed three-column',
        columns: ':gt(0)'
    }],
    initComplete:function(a, b){
        new $.fn.dataTable.FixedColumns(datatable, {
            leftColumns: 1
        });

        var clonedTable = document.querySelectorAll('.DTFC_Cloned');
        for (var i = 0; i < clonedTable.length; i++){
            clonedTable[i].id = 'DTFC_Cloned';
        }
        $('#DTFC_Cloned thead tr:eq(1) th:last-child').append(
            '<span id="fixed_col_filter_container"></span>'
        );

        yadcf.init(
            datatable,
            [
                {
                    column_number:1,
                    filter_container_id:"fixed_col_filter_container",
                    filter_type:"text",
                    filter_delay:"500"
                },{
                    column_number:2,
                    filter_container_id:"pc-pc_statut-2",
                    filter_type:"text",
                    filter_delay:"500"
                },{
                    column_number:3,
                    filter_container_id:"pc-reference_dossier-2",
                    filter_type:"text",
                    filter_delay:"500"
                }
            ],
            {language: tabLanguage}
        );
    }
});

1 个答案:

答案 0 :(得分:0)

我添加了对yadcf的修复并修复了你的代码,

抓住最新的0.9.0.beta.23并注意 column_number值为零(第一列应为column_number: 0,依此类推)

See it working here