scd
scd

Reputation: 164

Single column selection in DT datatable R

I know we can enable column selection instead of row selection for a DT::datatable like so:

DT::datatable(
  myTable, 
  selection = list(target = "column"))

And for row selection tables, we can enable single-select like so:

DT::datatable(
  myTable, 
  selection = "single")

However is there a way to combine the two and have a single-column selection? I've tried things like

selection = list(target = "column", select = "single")

or

selection = list(target = "column", selection = "single")

However nothing seems to work and I can't find anything in the doc either.

Upvotes: 2

Views: 1224

Answers (1)

Javier Orraca-Deatcu
Javier Orraca-Deatcu

Reputation: 221

You'll want to use the list argument "mode" as follows:

DT::datatable(
    myTable, 
    selection = list(mode = "single",
                     target = "column"))

I just ran into this myself and solved it reviewing the question by @MaMo on this other Stack Overflow post. Cheers and hope this helps.

Upvotes: 2

Related Questions