glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
627 stars 80 forks source link

use multiple elementids in the same reactable #336

Closed micboat closed 1 year ago

micboat commented 1 year ago

Is it possible to add multiple elementids. Example for filter input and download button like this: table <- reactable( df, columns = list( Group Indicator = colDef( filterInput = function(values, name) { tags$select( onchange = sprintf("Reactable.setFilter('grp-select', '%s', event.target.value || undefined)", name), tags$option(value = "", "All"), lapply(unique(values), tags$option), "aria-label" = sprintf("Filter %s", name), style = "width: 100%; height: 28px;" ) } ), elementId = c("grp-select","df_name") )

htmltools::browsable(
  htmltools::tagList(
    csvDownloadButton("df_name", "Download as CSV", filename = "Ratios.csv"),
    table
  )
)

It currently supports only one elementId

glin commented 1 year ago

Hi, that's not possible, each table can only have one unique ID. Is there any reason why both the filter and download buttons couldn't use the same table ID?

micboat commented 1 year ago

I can manage that with one ID. Thanks for the quick response & thanks for creating this tool. Very useful