【发布时间】:2021-04-20 02:43:02
【问题描述】:
我在下面有一个闪亮的应用程序,我在其中单击数据表行并在其旁边显示其索引。是否可以按Next 按钮并显示下一行的索引?表格的下一行也会相应地突出显示。
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(
title = 'Select Table Rows',
h1('A Server-side Table'),
fluidRow(
column(9, DT::dataTableOutput('x3')),
column(3, verbatimTextOutput('x4')),
actionButton("next","Next row")
)
),
server = function(input, output, session) {
# server-side processing
mtcars2 = mtcars[, 1:8]
output$x3 = DT::renderDataTable({datatable(selection = list(target = "row", mode = "single"),mtcars2 )})
# print the selected indices
output$x4 = renderPrint({
s = input$x3_rows_selected
if (length(s)) {
cat('These rows were selected:\n\n')
cat(s, sep = ', ')
}
})
})
【问题讨论】:
-
应该可以使用 Select 扩展,但这需要设置
server = FALSE。 -
这个可以吗?我在这里尝试将它与您的方法结合起来stackoverflow.com/questions/65712967/…