简体   繁体   中英

Get rows selected from Dt table shiny

WE all know that there is a built in function to get rows selected from DT table as shown below. Right now, whenever the user clicks on any row at any columns , the row numbers are printed. But that should not happen. Instead, only when he clicks on row at specific columns only, the row numbers should be printed. IS this possible

output$tab <- renderDT({
datatable(iris, selection = 'single',escape = F)
})

observerEvent(input$tab_rows_selected{
print("Clicked")
})

Yes, you can use the event cell_clicked :

output$tab <- renderDT({
datatable(iris, selection = 'single',escape = F)
})

observerEvent(input$tab_cell_clicked{
specific_col_index <- c(1, 3)
if (input$tab_cell_clicked$col %in% specific_col_index) {
print("Clicked")
}
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM