library(shiny) library(rhandsontable) tablecreater <- function(x, n, p=10, br=T) { m <- data.frame(matrix("", ncol = length(x), nrow = n)) m[] <- lapply(m, as.character) if (br) { colnames(m) <- colla(x, p) } else{ colnames(m) <- x } return(m) } colla <- function(x, plen=10){ if (length(plen) < length(x)) plen <- rep(plen[1], length(x)) for (i in (1:length(x))) x[i] <- paste(strwrap(x[i], width = plen[i]), collapse = "
") return(x) } cols <- c("US/Can", "Deviation", "MFG Product To Own Specs (Incl. Mix/Blend)", "MFG Product To Custom Specs (Tolling)", "MFG by 3rd Party (Tolling By Others)", "Distributor (No Repackaging, relabeling, mix / blend)", "Distributor (Repackaging and/or relabeling)", "Distributor (Foreign MFG)", "Broker / Drop Ship / MFG Rep (No Physical Possession)", "Processing", "Foreign Revenue") db <- tablecreater(cols, n=30, p=c(20, 20, 20, rep(20, 13))) tabgenerator <- function(x) { if (x=="GLCPLPLRating") return(GLCPLPLRatingtab()) } GLCPLPLRatingtab <- function() { return( tabPanel("GL CPL PL Rating", fluidRow( column(12, div(rHandsontableOutput("FixedSiteRevAdjTb", width = "1440px"), style="Font-size:65%") ) ) ) ) } ui <- shinyUI(fluidPage( title = 'Test Example of Comments', uiOutput("mainUI") )) server <- shinyServer(function(input, output, session) { output$mainUI <- renderUI({ do.call(tabsetPanel, lapply(c("GLCPLPLRating"), tabgenerator)) }) output$FixedSiteRevAdjTb <- renderRHandsontable({ kw <- rep(110, ncol(db)) kw[1] <- 60 kw[c(2)] <- 300 rhandsontable(db, selectCallback = TRUE, rowHeaders=NULL, strict=F, readOnly=T, useTypes=T, height =750) %>% hot_table(highlightCol = TRUE, highlightRow = TRUE) %>% hot_cols(colWidths= kw*0.9) %>% hot_col(1, halign="htCenter", readOnly=F, strict =F, type="dropdown", source=c("US", "Can")) %>% hot_cell(1, 3, "Test comment") }) }) runApp(list(ui=ui,server=server))