#ui.r
navbarPage(
"Application",
tabPanel("General",
sidebarLayout(
sidebarPanel(
uiOutput("book10")),
mainPanel(
DT::dataTableOutput("hot5")
)
)))
#server.r
library(shiny)
library(DT)
library(tidyverse)
server <- function(input, output,session) {
output$book10<-renderUI({
selectizeInput(
"bk10", "Select Items", choices =1:10000,multiple =T,selected = 1,
options = list(maxItems = input$bk1))
})
rt5<-reactive({
DF=data.frame(
Id= input$bk10,
Label=paste("Item",input$bk10),
sel=0,
stringsAsFactors = FALSE
)
if(is.null(input$hot5_rows_selected)|| is.na(input$hot5_rows_selected)){
DF
}
else{
DF<-gsub(1,0,DF[,3])
}
DF
})
output$hot5 <-DT::renderDataTable(
rt5()%>%
rowid_to_column("Row") %>%
mutate(Row = ""),
rownames = FALSE,
extensions = "Select",
options = list(
columnDefs = list(list(className = "select-checkbox", targets = 0, orderable = FALSE)),
select = list(style = "multi", selector = "td:first-child")
),
editable=TRUE
)
}
I create a datable which numbers of rows is set by the selectInput()
. The last collumn includes "0" by deafult but I would to replace this "0" with 1 when I select one row from the "Row" column.