Using the javascript datatable selection as opposed to DT::datatable selection

Hello,
I am trying to use a DT::datatable options with fixed columns and row selection.
The built-in DT selection won't work as documented https://github.com/rstudio/DT/issues/275
but the Selection extension will work see example here
https://datatables.net/release-datatables/extensions/FixedColumns/examples/integration/select.html.

My question is what is the right way to get the index of the selected row when using the datatable javascript built-in selection as opposed to the one from DT ?.

there is this link https://datatables.net/extensions/select/examples/api/get.html
but I dont know how to do it in a shiny context where the selected row would trigger a filter in a plot etc.

  datatable(mtcars,
            selection = "none",
            extensions = c('Select', 'Buttons',"FixedColumns", "FixedHeader", "Scroller"), 
            options = list(
              dom = 'Blfrtip',
              select = list(style = 'os', items = 'row'),
              buttons = c('selectAll', 'selectNone', 'selectRows'),
              scroller = TRUE,
              scrollX = TRUE,
              scrollY = "780px",
              fixedHeader = TRUE,
              class = 'cell-border stripe',
              fixedColumns = list(leftColumns = 2,heightMatch = 'none')
            )
  )

I guess you'd add a javascript callback to the DT that sets shiny input value binding.
https://shiny.rstudio.com/articles/communicating-with-js.html

found out that it was fixed in https://github.com/rstudio/DT/pull/744 might be good to update the docs.

we an get the index of selected rows using the usual way:
where tbl is the
output$tbl assigned to the datatable output

input$tbl_rows_selected

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.