Beasterfield
Beasterfield

Reputation: 7113

Subsetting shinyTable

I am currently playing around with shinyTable which is a shiny compatible implementation of HandsonTable (https://github.com/trestletech/shinyTable). By coincidence I realized, that if I add a logical column to the rendered data.frame the values will appear as clickable checkboxes. My hope was to use this to easily subset the table:

enter image description here

library(devtools)
# those versions are necessary to let shinyTable work with shiny
install_github( "shiny", "rstudio", ref="fcf963639e4839e5689665c257e7f488c9c34cc0" )
install_github( "shinyTable", "JackStat" )
library(shiny)
library(shinyTable)

runApp(list(
  ui = bootstrapPage( 
    htable( "tbl", clickId="tblClick", headers="provided")
  ),
  server = function(input, output) {
    output$tbl <- renderHtable({
      if( is.null( input$tbl ) ){
        return( data.frame( select = TRUE, value = 1:10  ) )
      } else{
        return( input$tbl[ input$tbl$select, ] )
      }
    })
  }
))

However, when unchecking the check boxes I'll get the following result:

enter image description here

Is anyone experienced with shinyTable and can give me an advice how to avoid this?

Alternatively:

Any other (for my users comfortable) method which let me create subsettable tables?

Upvotes: 3

Views: 1777

Answers (1)

jdharrison
jdharrison

Reputation: 30425

Less is more in this case

library(shiny)
library(shinyTable)

runApp(list(
  ui = bootstrapPage( 
    htable( "tbl", clickId="tblClick", headers="provided", readOnly = 'false')
  ),
  server = function(input, output) {
    output$tbl <- renderHtable({
      if( is.null( input$tbl ) ){
        return( data.frame( select = TRUE, value = 1:10  ) )
      }
    })

  }

))

Upvotes: 1

Related Questions