选择要在rhandsontable

时间:2018-02-18 13:38:07

标签: r datatable shiny 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以给我选择输入数量?

1 个答案:

答案 0 :(得分:1)

您可以将最小/最大行/列传递给函数: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)
    )
  }
)

enter image description here