Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
How do I use "String1.includes(String2)" in R shiny DataTable Javascript?

I'm very new to Javascript so maybe this has a very easy answer.
I am trying to create a searchpane that allows me to filter out rows based on a string value in a column of a DataTable, specifically, whether the value includes a given string, similar to this (the "includes(Edinburgh)" part of the middle searchpane), just in a shiny App, and I can't seem to figure out how to get it to work.
I already have a successfully working searchpane for filtering a number column by value, and the second searchpane is set up the same, just with a different return clause, yet only shows me an empty window for a searchpane.

The code is as below:

output$completeTable <- DT::renderDataTable ({
   datatable(  
        complete_Table, 
        options = list(
            dom = "Plfrtip",
            pageLength = 10, 
            columnDefs = list(  
                list(
                    searchPanes = list (
                        show = TRUE,
                        options = list(
                            list(
                                label = "big",
                                value = JS("function(rowData, rowIdx) { return (rowData[8] > 10000); }"
                                )
                            ),
                            list(
                                label = "small",
                                value = JS("function(rowData, rowIdx) { return (rowData[8] < 10000); }"
                                )
                            )
                        )
                    ),
                    targets = 8 
                ),
                list(
                    searchPanes = list (
                        show = TRUE,
                        options = list(
                            list(
                                label = "All",
                                value = JS("function(rowData, rowIdx) { return rowData[3].includes('All'); }"
                                )
                            ),
                            list(
                                label = "Media",
                                value = JS("function(rowData, rowIdx) { return rowData[3].includes('Media'); }"
                                )
                            )
                        )
                    ), 
                    targets = 3
                ),
                list(searchPanes = list(show = FALSE), targets = c(1,2,4:7,9:11) )
            ),
        ),              
        extensions = c('Select', 'SearchPanes')
    )
}, server = FALSE)

As I said, the first Searchpane works fine on its own, yet as soon as I add the second one the first one isn't visible/there anymore and the second one doesn't have any data or labels in it. I am assuming the problem is that I have to include the searchterms ("Media" and "All") in a different way, but I cannot figure out how.
Thank you very much in advance!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Ok, found this answer and while it isn't exactly what I wanted it mostly solves my problem.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda