I basically have the same question asked and answered here Fixing a column in Shiny DataTable while Scrolling Right Does not Work with the main key difference that my data table extension is Buttons and I can't change it since I need the users to be able to export the data to cxv, excel, and pdf. Still, I would need to block/freeze the first two columns. Is it possible to do that? Here is my datatable:
df <- datatable(df_data,
rownames= F,
filter = 'top',
#lengthChange = T,
extensions = "Buttons",
caption = paste0("Min, Median, Max - Unfiltered data."),
options = list(scrollX = TRUE
, autoWidth = TRUE
, pageLength = 5
#, columnDefs = list(list(width = '200px', targets = c(0) ))
, initComplete = JS("function(settings, json) {","$(this.api().table().header()).css({'font-size': '10px'});","}")
, dom = 'Blfrtip'
,searching = FALSE
, info = FALSE
#, fixedColumns = list(leftColumns = 2)
,buttons = c('copy', 'csv', 'excel', 'pdf')
))
I tried to add the fixedColumns parameter without success so far. Thanks