Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put filter of renderDataTable at the top in R shiny

I am using renderDataTable in R & Shiny to present my data, but the filter is positioned at the bottom of table. Is there any way to put it at the top of the table? Thanks in advance!

BTW, where can I find the option list of renderDataTable?

  mainPanel(
    tabsetPanel(
      tabPanel("Table",tableOutput("values")),
      tabPanel("Tree Plot",plotOutput("plot")),
      tabPanel("Segment Data",dataTableOutput("obs"))

I'm not familiar with CSS, can anyone give me some advice on how to edit CSS inside R function?

like image 586
Yoki Avatar asked Mar 24 '14 22:03

Yoki


People also ask

What is DT in R?

DT: A Wrapper of the JavaScript Library 'DataTables' Data objects in R can be rendered as HTML tables using the JavaScript library 'DataTables' (typically via R Markdown or Shiny). The 'DataTables' library has been included in this R package.


2 Answers

Another option is to modify the CSS. with this line

tags$head(tags$style("tfoot {display: table-header-group;}"))

You put this into your ui.R file like this

,tabPanel("MeSH"          ,tags$head(tags$style("tfoot {display: table-header-group;}"))
    ,fluidRow( ...
like image 123
userJT Avatar answered Oct 04 '22 21:10

userJT


This : How to place DataTables column filter on top : can help you with the CSS you'll need to modify to get the filter at the top.

You can look here : https://github.com/rstudio/shiny-examples/blob/master/012-datatables/server.R : for how to use the renderDataTable options and you should be able to see the correlation between the way those options are set and the options list for the jQuery DataTables proper.

like image 24
hrbrmstr Avatar answered Oct 04 '22 20:10

hrbrmstr