DT numeric search on HTML column

Hi everyone!

I have a DT column that includes escaped HTML, specifically numbers inside a div. I'd like this column to be searchable with a slider as a numeric column, ignoring the styled div, but I'm not quite sure how to execute. Any help or leads appreciated!

library(shiny)

test <- data.frame(
    column = c("<div class='test'>1</div>", "<div class='test'>2</div>", "<div class='test'>3</div>"),
    num = 1:3
)

ui <- fluidPage(
    DT::dataTableOutput("example")
)

server <- function(input, output, session) {

    output$example <- DT::renderDT({
        dtable <- DT::datatable(test,
                                escape = FALSE,
                                filter = list(position = "top", plain = TRUE),
                                rownames = FALSE,
        )
    })
}

shinyApp(ui = ui, server = server)

You may be able to achieve such an effect with some clever javascript, but I'm not aware of any pure R approach to achieve your desired effect. Except perhaps making a true numeric column from the div wrapped numeric column, and searching on that.

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.