如何删除数据表列中的填充

Zeu*_*eus 4 r shiny dt

有没有办法设置数据表选项来减少列填充?此链接建议autoWidth=TRUE与 with 一起使用scrollX=TRUE,但在我的代码中不起作用。

正如您在下图中所看到的,列之间有很大的差距,迫使用户滚动,如果可能,我希望避免这种情况。这个链接这个链接在java中有同样的问题

在此处输入图片说明

这是呈现数据表的代码。

output$book_table <-  DT::renderDT(RVTables$book %>% 
                                     filter(deal==as.numeric(input$deal_choice)),
                                   selection = list(mode="single",selected=row_edited),
                                   editable = TRUE,
                                   rownames = FALSE,
                                   options=list(
                                     autoWidth=TRUE,
                                     scrollX = TRUE,
                                     ordering=FALSE,
                                     pageLength=12,
                                     scrollY = TRUE,
                                     bLengthChange= FALSE,
                                     searching=FALSE
                                   )
)
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助。

Zeu*_*eus 7

经过一些谷歌搜索后,我发现了一行代码class="compact cell-border",,它减少了列标题周围的填充。这是我渲染表格的代码,以防它对其他人有帮助。

output$book_table <- DT::renderDataTable({    
    DT::datatable(
      deal_reactive(),
      editable = TRUE,
      rownames = FALSE,
      class="compact cell-border",
      selection = list(mode = "single", 
                       target = "row", 
                       selected = previous_row),
      options = list(
        dom="t",
        autoWidth=TRUE,
        scrollX = TRUE,
        ordering=FALSE,
        pageLength = 28, 
        bLengthChange= FALSE,
        displayStart = previous_page,
        searching=FALSE
        )
      )
  })
Run Code Online (Sandbox Code Playgroud)