I'm trying to use this JS script (from this website: https://datatables.net/blog/2021-09-17) in a DT data table:
var fsrco = $('#fuzzy-ranking').DataTable({ fuzzySearch: { rankColumn: 3 }, sort: [[3, 'desc']] }); fsrco.on('draw', function(){ fsrco.order([3, 'desc']); });
Use this script tag:
"//cdn.datatables.net/plug-ins/1.11.3/features/fuzzySearch/dataTables.fuzzySearch.js"
I want to incorporate this into a DT data table function in a Shiny application where a fuzzy search is applied using rank order (top has higher similarity), however, I don't want the rank column to be displayed. p>
Similar to this, but the ranking column is not displayed.
Some basic general examples:
library(shiny) library(DT) js <- c( " var fsrco = $('#fuzzy-ranking').DataTable({", " fuzzySearch: {", " rankColumn: 3", " },", " sort: [[3, 'desc']]", "});", "fsrco.on('draw', function(){", " fsrco.order([3, 'desc']);", "});" ) ui <- fluidPage( DTOutput("table") ) server <- function(input, output, session){ output[["table"]] <- renderDT({ datatable( iris, selection = "none", editable = TRUE, callback = JS(js), extensions = "KeyTable", options = list( keys = TRUE, url = "//cdn.datatables.net/plug-ins/1.11.3/features/fuzzySearch/dataTables.fuzzySearch.js" ) ) }) } shinyApp(ui, server)
This plugin is an old plugin and it does not work with the latest version of DataTables.
But we can take a JavaScript function that calculates similarity and use it in a custom search through the SearchBuilder extension.
First, copy this JavaScript code and save it under the name levenshtein.js: