Closed mmgledhill closed 6 years ago
First, you'll need to install both rstudio/DT@async
and ramnathv/htmlwidgets@async
. (Sorry, async gets its tendrils into everything; it'll be easier when all the relevant packages have gone to CRAN.)
Then, try rewriting the DT::renderDataTable
like so:
DT::renderDataTable({
promise_all(data = all_data_async(), cols = names_all_data_async()) %...>%
with({
datatable(data, options = list(
columnDefs = list(
list(
visible = FALSE,
targets = cols
)
),
dom="Bfrtip",
buttons=list('colvis')
))
})
})
See https://rstudio.github.io/promises/articles/combining.html for an explanation of the promise_all(...) %...>% with({ ... })
idiom.
The DT::renderDataTable
function's options
can't contain promises. But, you can rewrite the body of the renderDataTable
to take the resolved values of the promises, and make a regular options object, which fortunately can also be passed to DT::datatable
.
No longer able to hide columns based on column name from promises object with DT@async
See question on stackoverflow
Row {data-height=650}
Table