passing table options through ui (dataTableOutput) instead of server (renderDataTable)

已查看 11 次
跳至第一个未读帖子

Yoav Yoav

未读,
2017年10月22日 11:41:512017/10/22
收件人 Shiny - Web Framework for R
hello,

i'd like to be able to pass the table options as arguments in my ui.R file - the specific use case is to create a customized dataTableOutput function with customized options and styling.

the code from DT package looks like this:
dataTableOutput = function(outputId, width = '100%', height = 'auto') {
 htmltools::attachDependencies(
   htmlwidgets::shinyWidgetOutput(
     outputId, 'datatables', width, height, package = 'DT'
   ),
   crosstalk::crosstalkLibs(),
   append = TRUE
 )
}

i want be able to add the options argument here to dataTableOutput, as opposed to adding options through the server logic:
library(shiny)
library(DT)

ui = fluidPage(fluidRow(column(12,DT::dataTableOutput('tbl'))))
server = function(input, output) { 
  output$tbl <-  DT::renderDataTable(iris}, 
                                     options = list(lengthChange = FALSE)) }

shinyApp(ui,server)

how can i modify the dataTableOutput function to make it get the table options as an argument? should the change be made to htmlwidgets::shinyWidgetOutput, or to the datatable one?


any help would be greatly appreciated, thanks!

回复全部
回复作者
转发
0 个新帖子