shinyServer(function(input, output) {
dat <- list(cars,iris) #Produce my data sets
output$tabset <- renderUI({
tabs <- list()
for(i in c(1,2)){
id <- paste("id",i, sep="")
tabs[[i]] <- tabPanel(title=id,DT::dataTableOutput(outputId=id)) #dynamic panels
}
do.call(tabsetPanel,c(tabs, id='Panel'))
})
lapply(1:2,function(i){
id <- paste("id",i, sep="")
output[[id]] <- DT::renderDataTable({
dat[[i]]},
extensions = c('Responsive','Scroller'),
options=list(deferRender=TRUE, dom='T<"clear">fitrS', scrollY=540, searchHighlight = TRUE,
scrollCollapse=TRUE, autoWidth = TRUE,
columnDefs = list(list(width = '60%', targets = '_all',
render = JS("function(data, type, row, meta) {",
"return type === 'display' && data.length > 5 ?",
"'<span title=\"' + data + '\">' + data.substr(0, 5) + '... </span>' : data;",
"}"
)))),
escape=FALSE, rownames=TRUE,style = 'bootstrap' #- this somehow breaks rows_selected feature
,class = 'table-condensed', server=TRUE)
})
output$debug <- renderPrint({
id <- input$Panel
cat(input[[paste(id,"_rows_selected",sep="")]])
})
})