title: DataTable callback behaviour in R Shiny
body: <p>I have an issue for which I do not find any solution.
  I want to show a table in my shiny app with DT::datatable. In this tab, I want to color some cells which are defined by their coordinates. Here is an example of code where the colored cells corresponds to NA values :</p>
  
  <pre><code>test.table &lt;- data.frame(lapply(1:8, function(x) {1:1000}))
  test.table[c(2,3,7), c(2,7,6)] &lt;- NA
  id &lt;- which(is.na(test.table))
  
  
  datatable(test.table,
  options = list(drawCallback=JS(
  paste("function(row, data) {",
  paste(sapply(1:ncol(test.table),function(i)
  paste( "$(this.api().cell(",id %% nrow(test.table)-1,",",trunc(id / nrow(test.table))+1,").node()).css({'background-color': 'lightblue'});")
  ),collapse = "\n"),"}" ))
  ))
  </code></pre>
  
  <p>This code works fine when run in a R console (RStudio) but when I implement this in my shiny app, there is a little bug : on the first page, the colored cells are at the right place but when I click on the next button to view the other pages,it seems that the colored cells do nout update and they are still colored even is there are no NA anymore.
  Here is a working example on that problem:</p>
  
  <pre><code>shinyApp(
  ui = fluidPage(
      fluidRow(
          column(12,
          dataTableOutput('table')
         )
  )
  ),
  server = function(input, output) {
    test.table &lt;- data.frame(lapply(1:8, function(x) {1:1000}))
    test.table[c(2,3,7), c(2,7,6)] &lt;- NA
    id &lt;- which(is.na(test.table))
  
      output$table &lt;- renderDataTable(
          datatable(test.table,
                     options = list(drawCallback=JS(
                             paste("function(row, data) {",
                                 paste(sapply(1:ncol(test.table),function(i)
                                   paste( "$(this.api().cell(",id %% nrow(test.table)-1,",",trunc(id / nrow(test.table))+1,").node()).css({'background-color': 'lightblue'});")
                                    ),collapse = "\n"),"}" ))
          )))
  
  }
  )
  </code></pre>
  
  <p>I will be very happy if someone can help me for that problem</p>
  
  <p>Regards</p>
  
  <p>Sam</p>