FixedColumns for renderDataTable

875 views
Skip to first unread message

Mark Corrales

unread,
Feb 22, 2015, 12:24:12 AM2/22/15
to shiny-...@googlegroups.com
I have not been able to find a clear example that shows how to implement in shiny the FixedColumns extension for DataTables (http://datatables.net/extensions/fixedcolumns/).

Could someone post a complete example or tutorial of some kind on this? It seems like an essential functionality, to be able to freeze 1 or more columns in a data table. There are clear examples written in javascript, and there are examples of various callbacks in renderDataTable options, but I can't get FixedColumns working... This has been asked on stackoverflow and elsewhere but without a clear (to me, anyway) answer.

I think I have to first include the FixedColumns javascript, which might be done as described here?

Then, for example if I have some code like the following, what is the syntax that freezes the first 3 columns?

  output$colsout <- renderDataTable( 
    mycols, 
    options=list(
      scrollX= TRUE,
      scrollY= "500px",
      scrollCollapse= TRUE, 
      lengthMenu = list(c(10, 200, -1), c('10', '100', 'All')),
      pageLength = 100,
      columnDefs = list(list(width="440px", targets=list(0))),  # make the 1st column wide 
 ****      INSERT WHAT CODE HERE?  ***
    )
  )


Yihui Xie

unread,
Mar 5, 2015, 8:57:23 AM3/5/15
to Mark Corrales, shiny-discuss
You can find an example on the DT website:
http://rstudio.github.io/DT/ (specifically
http://rstudio.github.io/DT/extensions.html#fixedcolumns)

Regards,
Yihui
Reply all
Reply to author
Forward
0 new messages