DataTable How to prevent row selection/deselection in columns containing hyperlinks

datatable

#1

I am dealing with a datatable with clickable element. A column of the row contains a hyperlink. When the hyperlin is clicked I don't want the row click event to be fired or managed (to select / deselect).

What I have tried on R Shiny:

function preventDefault(e) {
   e.preventDefault();
   e.stopPropagation();

   return false;
}

The element in DataTable which contains link:

 <a href="#" onclick="preventDefault(event)";>

But nothing happend.

Full source code:

library(shiny)
library(DT)
library(dplyr)

ui <- fluidPage(

   # Application title
  DT::dataTableOutput("DTExample")


)

server <- function(input, output) {
  dat <- head(iris)

  dat <- dat %>% mutate(clickme = '<a href="#" 
                     onclick="event.preventDefault(); event.stopPropagation(); alert(event); return false;";
                     >CLICKME</a>')

  output$DTExample<- renderDataTable({
    datatable(dat, escape = FALSE, class = 'cell-border stripe')
  }) 
}

# Run the application 
shinyApp(ui = ui, server = server)

#2

The question has been answered @ https://stackoverflow.com/questions/51145207/r-shiny-datatable-how-to-prevent-row-selection-deselection-in-columns-containing