【发布时间】:2018-02-01 14:07:58
【问题描述】:
我的一些 DT 表似乎位于页面的中心(参见下面的图 1 和图 2)。如何使它们在左侧对齐,以便所有表格和绘图都很好地对齐。
生成第一个表的代码(“集群解决方案摘要”)
output$out_best <- DT::renderDataTable({
#if (input$act_access_k >0) {
DT::datatable(best_sols(), caption = "", rownames = TRUE,
options = list(autoWidth = TRUE, scrollX = TRUE,
columnDefs = list(list(width = '100px', targets = 1)),
paging = FALSE, searching = FALSE), selection='none') %>% formatRound(1:input$Bn, 3)
#}
})
我生成第二张表的代码(“...按集群分布”)
output$prop_by_cluster <- DT::renderDataTable({
if (input$act_next3 >0 & input$act_clust_sel>0) {
DT::datatable(profile_result(), class= 'compact stripe', caption = '',
rownames = F, options = list(autoWidth = TRUE, scrollX = TRUE,
columnDefs = list(list(width = '200px', targets = 1)),
paging = FALSE, searching = FALSE)) %>% formatPercentage(1: max(input$k)+2, 2)
}
})
编辑
添加之前 style = "float:left"
添加后样式 = "float:left"
【问题讨论】:
-
我用
renderDataTable做了很多尝试;但找不到与server对齐的方法。但是,您可以从ui执行此操作,如下所示:mainPanel(style = "float:left", dataTableOutput("out_best"), dataTableOutput("prop_by_cluster ")) -
Sagar - 您的建议可以对齐左侧的表格。然而,另一张桌子/情节似乎被弄脏了。请参阅我原始帖子中附加的图像。任何想法?谢谢!
-
看起来您的表格都是左对齐的,但有些列没有正确对齐。需要对齐这些。