I have a simple DT table that is summarised as shown below. Wanted to check we can add html table drop down when clicked on respective rows (on action button).
library(dplyr)
samdt <- structure(list(ColA = c("a", "a", "b", "b", "b"),
ColB = c("a1", "a1", "b1", "b2", "b2"),
ColC = c(1, 2, 3, 4, 5)), row.names = c(NA,-5L),
class = c("tbl_df", "tbl", "data.frame"))
new_sam <- samdt %>% group_by(ColA) %>% summarise(new_colc = n())
asd <- data.frame(a = c(HTML('<button id="as" type="button" class="btn btn-default action-button">More Info</button>'),
HTML('<button id="as1" type="button" class="btn btn-default action-button">More Info</button>')))
datatable(cbind(asd, new_sam),rownames = F,escape = F,
options = list(
columnDefs = list(
list(orderable = FALSE, className = 'details-control', targets = c(0))
)))
For example when clicked on row 1, we need to have drop down showing details of ColB and ColC like below
ColB ColC
a1 1
a1 2
Similarly when clicked on row 2, we need to have
ColB ColC
b1 3
b2 4
b2 5