R Shiny Colvis DataTable Visualization problem and datatable searchbox

302 views
Skip to first unread message

Nando Carmona

unread,
Jul 4, 2015, 1:41:09 PM7/4/15
to shiny-...@googlegroups.com
Hi everyone,

I have TableTools and ColVis working together, but, when clicking the  Show/hide columns button, the list mixes up with the values in the table underneath, and I cannot make the list disappear by clicking the button again or clicking anywhere else in the page (the example in the datatables page behaves correctly).

enter image description here

I've already seen a case like this one here (http://stackoverflow.com/questions/24629902/r-shiny-datatables-colvis-behavior). In that post they mention that shiny atm is not compatible with the current data.table version, and I'd like to know if there's any other solution around. Here's my code:


ui.R

library(shiny)

library(ggplot2)

addResourcePath('datatables','\\Users\\Ser\\Downloads\\DataTables-1.10.7\\DataTables-1.10.7\\media')
addResourcePath('tabletools','\\Users\\Ser\\Downloads\\TableTools-2.2.4\\TableTools-2.2.4')

shinyUI(fluidPage(

    #App title
    titlePanel(h1("List Manager")),
    
    sidebarLayout(
        sidebarPanel( 
                  
    
    #File Upload Manager
    fileInput('file1', 'Choose file to upload'),
    
    tagList(
      singleton(tags$head(tags$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.7/js/jquery.dataTables.min.js',type='text/javascript'))),
      singleton(tags$head(tags$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/TableTools.min.js',type='text/javascript'))),
      singleton(tags$head(tags$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/ZeroClipboard.min.js',type='text/javascript'))),
      singleton(tags$head(tags$link(href='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/css/TableTools.min.css',rel='stylesheet',type='text/css'))),
      singleton(tags$head(tags$script(src='//cdn.datatables.net/colvis/1.1.0/js/dataTables.colVis.min.js',type='text/javascript'))),
      singleton(tags$script(HTML("if (window.innerHeight < 400) alert('Screen too small');")))
    )),
    
    mainPanel(
    dataTableOutput("mytable"))
    
  )))


server.R

shinyServer(function(input, output) {
  output$mytable = renderDataTable({
  
    inFile <- input$file1
    if (is.null(inFile))
      return(NULL)
    read.table(inFile$datapath, header=TRUE, sep='')
    
  }, options = list(
    "dom" = 'TC<"clear">lfrtip',
    "colVis" = list(
      "activate"="click",
      "align"="right"),
    "oTableTools" = list(
      "aButtons" = list(
        "copy",
        "print",
        list("sExtends" = "collection",
             "sButtonText" = "Save",
             "aButtons" = c("csv","xls")
        )
      )
    )
      )
  )
})


Also I have another "easy" question, I think :) I'd like to search "<" ir ">" values in the searchboxes at the bottom of the table, but I can't make it work. I don't know if I have to add anything to the code so it can be done (such as "regexp" or similar). 


Thanks in advanced to everyone!!




Yihui Xie

unread,
Jul 5, 2015, 10:10:24 PM7/5/15
to Nando Carmona, shiny-discuss
This was cross-posted at http://stackoverflow.com/q/31224010/559676

Regards,
Yihui

On Sat, Jul 4, 2015 at 12:41 PM, Nando Carmona <nando...@gmail.com> wrote:
>
> Hi everyone,
>
> I have TableTools and ColVis working together, but, when clicking the Show/hide columns button, the list mixes up with the values in the table underneath, and I cannot make the list disappear by clicking the button again or clicking anywhere else in the page (the example in the datatables page behaves correctly).
>

Nando Carmona

unread,
Jul 6, 2015, 2:27:30 AM7/6/15
to shiny-...@googlegroups.com, nando...@gmail.com
Sorry for the duplicity, thought they were independent forums (still learning :)

regards! 
Reply all
Reply to author
Forward
0 new messages