Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny, Remove Within-Column Filters from DataTables

[also posted in Shiny Google Group]

I am encountering some (I believe) unexpected behavior when I attempt to display a dataTable. When I display the table, my goal is to remove the majority of the sort/pagination/filter/processing options. So far setting bSort=0, bProcessing=0, bPaginate=0, bInfo=0 appears to produce desired results. However when I set bFilter=0, only the "global" filter box in the upper right had corner is removed; the within-column filter boxes remain (I expected bFilter=0 to remove all filter boxes).

Can anyone help with code to remove the within-column filter boxes (please and thank-you). [Also, I am aware of the column-specific format options, but have so-far been unable to implement them successfully to eliminate the within-column formats]. I have included minimal code below to reproduce the problem:

shinyUI(pageWithSidebar(

  #my code has a header panel;
  headerPanel("Table Example"),

  #my code has a sidebar panel;
  sidebarPanel(helpText("Stuff Here")),

  #table is displayed in the main panel;
  mainPanel(dataTableOutput("myTable"))
))


shinyServer(function(input, output) {

  #example dataTable that produces undesired result;
  output$myTable <- renderDataTable({
    as.data.frame(matrix(sample(1:10,100,replace=TRUE),nrow=20,ncol=10))
  }, options = list(bFilter=0, bSort=0, bProcessing=0, bPaginate=0, bInfo=0))

})

[Behavior appears both running from server and locally. Shiny 0.7.0.99. Using Google Chrome]

Thanks-in-advance!

like image 526
Jason LaCombe Avatar asked Nov 13 '13 13:11

Jason LaCombe


1 Answers

The solution was to simply edit the css associated with the myTable output object:

I.e. change:

mainPanel(dataTableOutput("myTable"))

to

mainPanel(
  dataTableOutput("myTable"),
  tags$style(type="text/css", '#myTable tfoot {display:none;}')
) 
like image 137
Jason LaCombe Avatar answered Oct 24 '22 20:10

Jason LaCombe