在悬停时获取R Shiny tableOutput的row.name

时间:2013-10-13 03:58:01

标签: r shiny xtable

我想为R shiny创建一个反应性输入,它会在悬停时返回表格行的row.name

在R Shiny中,表格由renderTable制作,并通过tableOutput输出。

这应该类似于已经构建的plotID和plotOutput的hoverID(分别用于click& hover)。

我还不太了解JavaScript或jQuery,但仍然按照这些说明自行构建:

http://rstudio.github.io/shiny/tutorial/#building-inputs

谢谢!


更新

这是我到目前为止的jQuery:

$(document).on('hover', '.table-hover tr', function(){
        var el = $(this);
        $(this).closest("tr").index();
}); 

var selectRowBinding = new Shiny.InputBinding();
$.extend(selectRowBinding, {
        find: function(scope) {
        return $(scope).find(".table-hover");
        },
        getValue: function(el){
        return $(el).closest("tr").index();
        },
        setValue: function(el, value) {
        },
        subscribe: function(el, callback) {
        $(el).on("change.selectRowBinding", function(e) {
        callback();
        });
        },
        unsubscribe: function(el) {
        $(el).off(".selectRowBinding");
        }
});
Shiny.inputBindings.register(selectRowBinding);

input$selectRowBinding仍然返回NULL。 我很确定我没有正确定义了绑定。

我一直在研究这两种资源:

https://groups.google.com/forum/#!searchin/shiny-discuss/selectablerows/shiny-discuss/ZaYYmFLHA6U/-cL62wQp0HUJ

Shiny R application that allows users to modify data

0 个答案:

没有答案