inst/example/app.r

library(shiny)
library(shinyNewColumns)
library(DT)
library(stringr)

options(shiny.fullstacktrace = FALSE)

# UI
ui <- fluidPage(
  includeCSS("www/style.css"),
  title = "shinyNewColumns",
  a(img(src="github.png", style="float:right; height:65px; padding-top:5px;"),
    href = "https://bit.ly/snc_new_issue"),
  h1(div(img(src="shinyNewColumnsv7_flat_wYellowStars.png",
             style=" padding-left:3px; height:100px;"),
         "shinyNewColumns"), align = "center"),
  br(), br(),
  # just a button next...
  fluidRow(column(12, align = "center", mod_launchModal_ui("snc"))),
  br(),
  h3("New column's code:"),
  h4("(generated by user inputs)"),
  verbatimTextOutput("display_expr"),
  br(),
  h3("Iris data:"),
  wellPanel(dataTableOutput("display_data"))
)

# Server
server <- function(input, output) {
  out <- mod_launchModal_srv("snc", dat = iris)
  output$display_expr <- renderPrint(out$expr())
  output$display_data <- renderDataTable({
    DT::datatable(
      out$data(), ### left off here
      extensions = 'Buttons',
      options = list(
        dom = 'Blftpr',
        pageLength = 15,
        lengthMenu = list(c(15, 50, 100, -1),c('15', '50', '100', "All")),
        buttons = list(list(
        extend = "excel",
        filename = paste("Iris_dwnld",str_replace_all(str_replace(Sys.time(), " ", "_"),":", "-"), sep = "_")
        ))
      )
      , style="default"
    )
  })
}

shinyApp(ui = ui, server = server)
AARON-CLARK/shinyNewColumns documentation built on May 1, 2022, 8:02 p.m.