Can someone advise me on how to fix column headers in an rhandsontable
? Below there is a sample script I have written, but it does not work. It seems that I could not use hot_cols()
in a proper way. I need help to amend this script or get an alternative one for this task.
library(shiny)
library(shinydashboard)
library(rhandsontable)
# Define the UI
ui <- dashboardPage(
dashboardHeader(title = "Fixed Column Headers"),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(
title = "Table with Fixed Column Headers",
width = 12,
solidHeader = TRUE,
status = "primary",
rHandsontableOutput("table")
)
)
)
)
# Define the server logic
server <- function(input, output) {
output$table <- renderRHandsontable({
rhandsontable(data = iris, readOnly = TRUE, width = "100%", height = "400px") %>%
hot_cols(colHeaderClassName = "fixed-header")
})
}
# Run the application
shinyApp(ui, server)