The problem: Including an emoticon to a parent/child table mutes the child table. How to overcome this difficulty?
The added issue is that the inclusion of virtually any special character leads to the same result. I suspect that the answer is in the call back but it beats my JS skills.
The code:
library(shiny)
library(DT)
library(tidyverse)
### == script knicked from https://github.com/rstudio/shiny-examples/issues/9
shinyApp(
ui = fluidPage(DT::DTOutput("tbl")),
server = function(input, output, session) {
df <- tibble(names=c("Joan", "Michael", "Vincent"), hex =c("🦁","🦁","🦁"), DOB=c("2020-04-05", "2020-04-05","2020-04-05"))
df <- df %>%
as.data.frame() %>%
nest(-names, -hex)
# add control column
data <- df %>% {bind_cols(data_frame(' ' = rep('►',nrow(.)))
,.)}
# get dynamic info and strings
nested_columns <- which(sapply(data,class)=="list") %>% setNames(NULL)
not_nested_columns <- which(!(seq_along(data) %in% c(1,nested_columns)))
not_nested_columns_str <- not_nested_columns %>% paste(collapse="] + '_' + d[") %>% paste0("d[",.,"]")
# The callback
# turn rows into child rows and remove from parent
callback <- paste0("
table.column(1).nodes().to$().css({cursor: 'pointer'});
// Format data object (the nested table) into another table
var format = function(d) {
if(d != null){
var result = ('<table id=\"child_' + ",not_nested_columns_str," + '\">').replace('.','_') + '<thead><tr>'
for (var col in d[",nested_columns,"]){
result += '<th>' + col + '</th>'
}
result += '</tr></thead></table>'
return result
}else{
return '';
}
}
var format_datatable = function(d) {
var dataset = [];
for (i = 0; i < + d[",nested_columns,"]['DOB'].length; i++) {
var datarow = [];
for (var col in d[",nested_columns,"]){
datarow.push(d[",nested_columns,"][col][i])
}
dataset.push(datarow)
}
var subtable = $(('table#child_' + ",not_nested_columns_str,").replace('.','_')).DataTable({
'data': dataset,
'autoWidth': false,
'deferRender': true,
'info': false,
'lengthChange': false,
'ordering': true,
'paging': false,
'scrollX': false,
'scrollY': false,
'searching': false
});
};
table.on('click', 'td.details-control', function() {
var td = $(this), row = table.row(td.closest('tr'));
if (row.child.isShown()) {
row.child.hide();
td.html('►');
} else {
row.child(format(row.data())).show();
td.html('▼');
format_datatable(row.data())
}
});
"
)
DDT <- datatable(
data,
escape = -c(2,4), # raw HTML in column 2
options = list( paging=FALSE,info = FALSE,
columnDefs = list(
list(visible = FALSE, targets = c(0,nested_columns) ), # Hide row numbers and nested columns
list(orderable = FALSE, className = 'details-control', targets = 1) # turn first column into control column
)
),
callback = JS(callback)
)
output$tbl <- DT::renderDT({
DDT
}, server = FALSE, width = 6)
session$onSessionEnded(function() {
observe(cat(paste0("Ended: ", values$sessionId)))
})
if(format(Sys.time(), "%M")=='00'){
onStop(function() {
dbDisconnect(con)
})
}
# you need set the server to FALSE
},
options = list(port = 33333)
)
Any thoughts?

In order to make a datatable with children, it's better to use the method I give on my blog. Currently there are some mistakes in the callback code, I need to update this post, so I provide the full code here for your case: