Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!