Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda