【发布时间】:2015-06-29 22:39:32
【问题描述】:
我们正在尝试重新创建示例:https://demo.shinyapps.io/029-row-selection/ ,使用 DT 包而不是闪亮包来渲染数据帧。 DT::Datatable 也有 'callback' 选项,但在使用与演示中相同的 javascriptcode 时,它似乎不起作用。
我们当前的代码:
shinyServer(function(input, output) {
output$tbl <- DT::renderDataTable(
DT::datatable(mtcars,options = list(pageLength = 10,
callback = JS("function(table) {
table.on('click.dt', 'tr', function() {
$(this).toggleClass('selected');
Shiny.onInputChange('rows',
table.rows('.selected').indexes ().toArray());
});
}")
))
)
output$rows_out <- renderText({
paste(c('You selected these rows on the page:', rows),
collapse = ' ')
})
})
有谁知道如何做到这一点?
提前非常感谢, 托马斯
PS:在以下示例中,我们发现了如何为数据表中的列着色: renderDataTable Select all cells containing value > 10 and highlight
【问题讨论】: