rstudio / DT

R Interface to the jQuery Plug-in DataTables
https://rstudio.github.io/DT/
Other
599 stars 180 forks source link

Add search result highlighting #871

Open abalter opened 4 years ago

abalter commented 4 years ago

I was looking at the extensions directory for some guides for how make one. All the code is minimized.

Simple implementations are found in here and contained links:

https://stackoverflow.com/questions/36176442/highlight-search-result-in-datatables

There is also a dedicated plugin:

https://github.com/julmot/datatables.mark.js

What would be the approach to make this an extension for R-DT?

stla commented 3 years ago
library(DT)
dtable <- datatable(iris[c(1,2,51,52,101,102),], 
                    options = list(
                      mark = list(accuracy = "exactly")
                    )
)
dep1 <- htmltools::htmlDependency(
  "datatables.mark", "2.0.1", 
  src = c(href = "https://cdn.datatables.net/plug-ins/1.10.19/features/mark.js"),
  script = "datatables.mark.min.js")
dep2 <- htmltools::htmlDependency(
  "jquery.mark", "8.11.1", 
  src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1"), 
  script = "jquery.mark.min.js")
dtable$dependencies <- c(dtable$dependencies, list(dep1, dep2))
dtable
abalter commented 3 years ago

Is that an extension?

stla commented 3 years ago

It's a plugin.