如何使用JavaScript回调在数据表中选择特定的单元格值数据?

时间:2019-05-13 09:32:23

标签: javascript r datatables callback dt

我的问题是我有一个数据表,其中添加了由行向量形成的辅助列,以便能够在下拉子行中选择这些值,但我不明白我做错了什么

图:

目前,这些值是手动引入的,等待知道如何调用它们。

这是Javascript代码, 谢谢你:

callback = JS("table.column(1).nodes().to$().css({cursor: 'pointer'});
    
        var table = document.getElementById('DataTables_Table_2');
        ro = table.cell(1); //don't work
        var space1 = ' ';
        var spaces_ant = space1.repeat(44);
        var spaces_ent = space1.repeat(30);
        var eads1 = '41565.01          ' + ro + spaces_ent + '40197.9892121137' + spaces_ent + '39705.423012079 ' + spaces_ent + '41565.01          ' + spaces_ent + '40798.594749117 ' + spaces_ent + '40197.9892121137' + spaces_ent + '39705.423012079 ';
        var eads2 = '2069.7            ' + spaces_ent + '   2480.56335944119' + spaces_ent + '2694.33212661556' + spaces_ent + '2777.49674727405' + spaces_ent + '2069.7            ' + spaces_ent + '2480.56335944119' + spaces_ent + '2694.33212661556' + spaces_ent + '2777.49674727405';
        var eads3 = '1899.83           ' + spaces_ent + '2182.45121972805' + spaces_ent + '2486.40183002769' + spaces_ent + '2802.58029312886' + spaces_ent + '1899.83           ' + spaces_ent + '2182.45121972805' + spaces_ent + '2486.40183002769' + spaces_ent + '2802.58029312886';
    
        var format = function(d) {
            return '<div style=\"background-color:#eee; padding: .5em;\"> EAD_S1 ' + spaces_ant + eads1 + '</div>'
                +
                '<div style=\"background-color:#eee; padding: .5em;\"> EAD_S2 ' + spaces_ant + eads2 + '</div>'
                +
                '<div style=\"background-color:#eee; padding: .5em;\"> EAD_S3 ' + spaces_ant + eads3 + '</div>'
                +
                '<div style=\"background-color:#eee; padding: .5em;\"><a href=\"#shiny-tab-PDriskparameters\" data-toggle=\"tab\" data-value=\"PDriskparameters\" aria-expanded=\"false\" class=\"action-button shiny-bound-input\"><i class=\"fa fa-bar-chart-o\"></i>Come Back to EAD</a></div>';
        };
    
        table.on('click', 'td.dt-center', function() {
            var td = $(this),
                row = table.row(td.closest('tr'));
    
            if (row.child.isShown()) {
                row.child.hide();
                td.html('&oplus;');
            } else {
                row.child(format(row.data())).show();
                td.html('&CircleMinus;');
            }
        });
        "
    )# callback - end

0 个答案:

没有答案