【问题标题】:How to add the check box and button in jquery data table column如何在jquery数据表列中添加复选框和按钮
【发布时间】:2013-02-19 16:24:24
【问题描述】:

我需要在 jquery 数据表的所有行中添加复选框和按钮。复选框需要添加第一列,按钮需要添加最后一列。使用 mvc 格式。我试试下面的代码。但它只显示按钮。如何在第一列中添加复选框

【问题讨论】:

  • html 中的复选框通常是输入元素的一部分: Option
  • 我试过了,但不使用。同样,我尝试使用相同的按钮它也没有响应

标签: jquery html model-view-controller datatables


【解决方案1】:

这样使用:

"aoColumnDefs": [{
                "aTargets": [0],
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    if (iCol == 0) {
                       $('<input type=\"checkbox\" value="' + sData + '">');
                    }
                }
            },
            {
            "aTargets": [7],
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    if (iCol == 7) {
                        var b = $('<button>test</button>');
                        b.on('click', function () {
                        });
                        $(nTd).empty();
                        $(nTd).prepend(b);
                    }
                }
            }],

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 2019-02-02
    • 1970-01-01
    • 2020-12-20
    • 1970-01-01
    • 2011-05-12
    • 2015-02-11
    相关资源
    最近更新 更多