I would like to display a data table in an R Shiny dashboard using DT, where the user can enter measurement values in the “Value” column. All other columns should not be editable. The “Tooltip” column should not be displayed but should appear as a tooltip when the user hovers over a value in the “Param” column. Then, the process of entering a value in the “Value” column should work without needing to double-click on the cell. Is it possible to have the input field permanently displayed by default in all cells of the “Value” column?
library(shiny)
library(shinydashboard)
library(DT)
data <- data.frame(
Param = c("FVC", "FEV1", "FEV1/FVC ratio"),
Tooltip = c("forced vital capacity", "forced expiratory volume exhaled in the first second", "tiffeneau index"),
Unit = c("l", "l", "%"),
Value = c(NA, NA, NA)
)
data
# UI
ui <- dashboardPage(
dashboardHeader(title = "Test"),
dashboardSidebar(disable = TRUE),
dashboardBody(
DTOutput("table")
)
)
# Server
server <- function(input, output, session) {
output$table <- renderDT({
datatable(
data,
options = list(
dom = 't',
paging = FALSE,
ordering = FALSE
),
selection = 'none',
rownames = FALSE,
editable = list(target = 'cell', disable = list(columns = c(0, 1, 2)))
)
}, server = FALSE)
}
# Shiny-App starten
shinyApp(ui = ui, server = server)