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!