每个按钮的复选框以在没有 ColVis 的情况下选择 Datatables 1.10 中的一列 [英] Checkbox for each button to select a column in Datatables 1.10 without ColVis

查看:10
本文介绍了每个按钮的复选框以在没有 ColVis 的情况下选择 Datatables 1.10 中的一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 ColVis 在 Datatables 1.10 中已被弃用,我正在寻找一种方法来为每个按钮添加一个复选框,以在此example 使用 ColVis.

As ColVis is deprecated in Datatables 1.10, I am looking for a way to add a checkbox to each button to select a column in the table in the same way it is done in this example that uses ColVis.

在以下 JSFiddle 中是我到目前为止所做的.以下是我正在使用的代码.

In the following JSFiddle is what I have done so far. Below is the code that I am using.

$(document).ready(function() {
var table = $('#example').DataTable( {
    dom: 'B',
    "buttons": [
                {
                    extend: 'colvis',
                    postfixButtons: [
                        {
                            extend: 'colvisRestore',
                            text: 'Restore'
                        }
                    ],
                    buttons : [{
                        extend: 'columnsToggle',
                    }],
                }
            ],
    }
); } );

我非常感谢您分享这方面的专业知识.

I would really appreciate your share of expertise on this one.

推荐答案

SOLUTION

复选框已被插入/开始样式取代.但是,您可以使用 CSS 模拟复选框,请参阅以下规则:

SOLUTION

Checkboxes has been replaced by inset/outset styles. However you can simulate a checkbox using CSS, see the rules below:

.dt-button-collection a.buttons-columnVisibility:before,
.dt-button-collection a.buttons-columnVisibility.active span:before {
    display:block;
    position:absolute;
    top:1.2em;
    left:0;
    width:12px;
    height:12px;
    box-sizing:border-box;
}

.dt-button-collection a.buttons-columnVisibility:before {
    content:' ';
    margin-top:-6px;
    margin-left:10px;
    border:1px solid black;
    border-radius:3px;
}

.dt-button-collection a.buttons-columnVisibility.active span:before {
    content:'2714';
    margin-top:-11px;
    margin-left:12px;
    text-align:center;
    text-shadow:1px 1px #DDD, -1px -1px #DDD, 1px -1px #DDD, -1px 1px #DDD;
}

.dt-button-collection a.buttons-columnVisibility span {
    margin-left:20px;    
}

演示

有关代码和演示,请参阅此 jsFiddle.

请参阅我的其他答案,解释为什么 action 不适用于 columnsToggle 按钮.

See my other answer to your question explaining why action will not work for columnsToggle button.

这篇关于每个按钮的复选框以在没有 ColVis 的情况下选择 Datatables 1.10 中的一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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