【问题标题】:Single column selection in DT datatable RDT数据表R中的单列选择
【发布时间】:2021-05-20 10:03:39
【问题描述】:

我知道我们可以像这样为 DT::datatable 启用列选择而不是行选择:

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

对于行选择表,我们可以像这样启用单选:

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

但是有没有办法将两者结合起来并进行单列选择?我尝试过类似

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

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

但是似乎没有任何效果,我在文档中也找不到任何内容。

【问题讨论】:

    标签: r datatable dt


    【解决方案1】:

    您需要使用列表参数“mode”,如下所示:

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

    我自己遇到了这个问题,并通过@MaMo 在这个other Stack Overflow post 上查看问题解决了它。干杯,希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2016-05-12
      • 1970-01-01
      • 2018-05-28
      • 2019-07-17
      • 1970-01-01
      • 2015-10-02
      • 2020-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多