I have a dataset with a nested list column which I am passing to DT's createdCell
function.
However, I want the use the FIRST number in the list for the column's range slider. I know DT has an internal function that is used to generate these sliders based on the column's type, but I was wondering if there is a way to set a custom filter/range?
I don't want to use the render
function because I do need the list data to persist into the DT object, but I want to filter based on other data. Is that possible? Maybe there's a searching method within datatables I can leverage??
library(dplyr)
dat <- data.frame(
a = letters[1:2],
b = 1:2,
c = I(
list(
list(
3,
list(aa = 1, bb = 1),
list(aa = 2, bb = 2)
),
list(
4,
list(aa = 3, bb = 3),
list(aa = 4, bb = 4)
)
)
)
)
DT::datatable(
dat,
# can I make a custom filter
# and for the third column set it to the first number
# before the list?
# creating a 3-4 range for column 3?
filter = "top",
options = list(
# here I need the list so I cant just use the render function
# maybe there's some argument where I can pass the array of values I want to use in the slider?
columnDefs = c(list(list(targets = 3,
createdCell = DT::JS('
function(td, cellData, rowData, row, col) {
console.log(cellData)
}
'))
)
)
)
)