neversaint
neversaint

Reputation: 63984

How to do exact search in Shiny DataTables column

I have the following self-sufficient Shiny script:

mydf <- data.frame(commonality=c("common","uncommon","common","uncommon","common"),value=c(1,2,3,4,5))

library(shiny)
shinyApp(
  ui = fluidPage(DT::dataTableOutput('tbl')),
  server = function(input, output) {
    output$tbl = DT::renderDataTable(
      mydf, options = list(lengthChange = FALSE)
    )
  }
)

Which produces this:

enter image description here

What I want to do is to do exact search. For example when I type common, the values uncommon should not appear. How can I do that?

Upvotes: 1

Views: 728

Answers (1)

R.B
R.B

Reputation: 517

You can use the filter of the DT package :

 library(shiny) 
    shinyApp( ui = fluidPage(DT::dataTableOutput('tbl')), 
    server = function(input, output) { 
    output$tbl = DT::renderDataTable( mydf,filter = 'top', options = list(lengthChange = T, dom = 'tip') )
      })

and the result look like this : enter image description here

Upvotes: 1

Related Questions