select 在 rhandsontable 中预览的行数

select number of rows to preview in rhandsontable

使用数据表时,一切都很清楚 - 我可以选择 5、10、25、50 或 100 个条目。

shinyApp(
  ui = fluidPage(
    fluidRow(
      column(12,
             dataTableOutput('table')
      )
    )
  ),
  server = function(input, output) {
    output$table <- DT::renderDataTable(iris)
  }
)

不幸的是,我在 rhandsontable 中找不到合适的解决方案。我唯一的结果是:

 shinyApp(
      ui = fluidPage(
        fluidRow(
      column(12,
             rHandsontableOutput('table')
      )
    )
  ),
  server = function(input, output) {
    output$table <- renderRHandsontable(
      rhandsontable(iris, width = 550, height = 300)
    )
  }
)

我如何强制 rhandsontable 为我提供带有条目数的 selectinput?

您可以将min/max rows/columns传递给函数:https://github.com/handsontable/handsontable/issues/225

library(shiny)
library(rhandsontable)

shinyApp(
  ui = fluidPage(
    fluidRow(
      column(12,
             sliderInput('input', label = "Rows",
                         min = 1, max = nrow(iris), value = 10)
      ),

      column(12,
             rHandsontableOutput('table')
      )
    )
  ),
  server = function(input, output) {
      output$table <- renderRHandsontable(
        rhandsontable(iris, width = 550, height = 300, maxRows = input$input)
    )
  }
)