【问题标题】:Conditionally Add Checkbox to handsontable有条件地将复选框添加到handsontable
【发布时间】:2013-03-01 10:14:25
【问题描述】:

如何为复选框添加条件格式。 EX:如果一行在至少一列中有数据,我有 13 列和 4000 行,将复选框添加到第一个单元格。如果一行中的所有单元格都有数据,则选中该复选框。复选框也应该有 id。

我会得到类似的数据

[["<input type='checkbox' name='1'","a","a","a","a","a"...],
["<input type='checkbox' name='2'","a","a","a","a","a"...],
["<input type='checkbox' name='3'","a","a","a","a","a"...]....];

我需要加载它,如果用户对单元格进行任何删除或更新,我需要检查复选框状态。 我在用 请帮帮我...

【问题讨论】:

    标签: jquery handsontable


    【解决方案1】:

    加载时像这样......

    // run through each row in the table
    checkCellsForStuff = $('#myTable tr').each(function() {
        var cellHasStuff = 0;
    
        // check each cell in the current row
        $('td', this).each(function() {
            if ($(this).text()) { cellHasStuff = 1 }
        });
    
        // add a checkbox to the first cell in the current row
        if (cellHasStuff = 1) {
            $(this).('td').first().html('<input type="checkbox">');
        }
    });
    

    然后,对于点击...

    $('#myTable td').blur(function() {
        checkCellsForStuff();
    });
    

    这是未经测试的,但应该可以帮助您入门。

    【讨论】:

    • 您好,感谢您的回复。这是一种方式,但我正在寻找任何渲染类型的格式。因为上面给出了 4000 行和 13 列的性能问题..
    • 还有一件事我必须在加载handsontable时添加复选框..
    • 第一部分进行检查并添加负载。
    猜你喜欢
    • 2013-04-30
    • 1970-01-01
    • 2014-10-31
    • 2012-06-16
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 2018-07-19
    • 1970-01-01
    相关资源
    最近更新 更多