I am trying to create a brilliant application that uses the FixedColumns plugin:
https://datatables.net/extensions/fixedcolumns/
My dataset will contain about 100 columns, and I want to fix the first five columns and allow the user to scroll through the rest. The examples show that I will need to use this javascript:
https://datatables.net/release-datatables/extensions/FixedColumns/examples/two_columns.html
$(document).ready(function() { var table = $('#example').DataTable( { scrollY: "300px", scrollX: true, scrollCollapse: true, paging: false } ); new $.fn.dataTable.FixedColumns( table, { leftColumns: 2 } ); } );
I don't know javascript, but in the past I could use I () to insert javascript parameters. This time, although it seems like I need to do something else. I tried the code below and received the message: "ERROR:" parameters "must be a named list."
library(shiny) library(ggplot2) data(diamonds) hw <- diamonds runApp( list(ui=( fluidPage( tabsetPanel( id = 'dataset', tabPanel('hw', dataTableOutput('mytable1')) ))), server = (function(input, output, session) { output$mytable1 <- renderDataTable( head(hw, 50), options = list(scrollY = '300px', scrollX = TRUE, scrollCollapse = TRUE, paging = FALSE, I("new $.fn.dataTable.FixedColumns( table, { leftColumns: 5 } );") )) }) ))
source share