Reputation: 985
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")
})
Upvotes: 1
Views: 486
Reputation: 10365
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")
}
})
Upvotes: 3