title: Interactive datatable: keep column filters after rerendering the table
body: <p>First time poster here.  I'm usually able to get all my answers without posting but this one really stumps me.  I'm an intermediate R user with NO javascript experience whatsoever.  Here's what I'm trying to do:</p>
  
  <p>I have a datatable that uses both interactive shiny filters via action buttons which subset my data, and also the built in datatable filters.  The action buttons perform bulk filtering by subsetting the dataframe.  The problem I'm having is that whenever one of these bulk filters is applied, the datatable is re-rendered and all the individual column filters are cleared.  I'd like to be able to keep the individual column filters active whenever the data is subsetted and the table re-rendered.</p>
  
  <p>I've managed to find that I can output and isolate this information from the datatable using input$mytable_search_columns but I have no idea how to write that javascript that will apply this criteria upon re-rendering the table.</p>
  
  <pre><code>library(shinyBS)
  library(DT)
  
  server &lt;- function(input, output, session) {
  
    df &lt;- reactive({iris})
  
    df.sub &lt;- reactive({
      if(input$buttonfilter == 0){
        df.sub &lt;- df()
      }
      if(input$buttonfilter == 1){
        df.sub &lt;- subset(df(), subset = Species == 'setosa')
      }
      df.sub
    })
  
    output$mytable &lt;- DT::renderDataTable(df.sub(),
                                          filter = 'top')
    output$filters &lt;- renderText({input$mytable_search_columns})
  }
  ui &lt;- fluidPage(
    h3('Button Toggle Filter'),
    bsButton("buttonfilter","Show only Setosa", type = 'toggle'),
    br(),
    br(),
    h3('Current filters'),
    textOutput('filters'),
    br(),
    br(),
    DT::dataTableOutput('mytable')
  
  
  
  )
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Thanks so much.</p>
  
  <p>EDIT:</p>
  
  <p>OK I've made it so that it should be reproducible (requires shinyBS and DT packages).</p>
  
  <p>What I'm trying to do is find a way to maintain the current DT filters when the table is re-rendered based on the subset initiated by the action button.  In this example you can see the filters are cleared once the table is re-rendered.</p>
  
  <p>Thank you!</p>