搜索
查看: 1310|回复: 0

设置shiny的DT表格的每一列居中显示

[复制链接]

634

主题

1182

帖子

4030

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
4030
发表于 2017-7-6 11:27:59 | 显示全部楼层 |阅读模式
本身DT就是一个JavaScript开发的插件,跟其他语言结合都可以。
如果要设置shiny的DT表格的每一列居中显示,用法如下:
[AppleScript] 纯文本查看 复制代码
 library(DT)
 datatable(head(iris), rownames = FALSE, options = list(
 columnDefs = list(list(className = 'dt-center', targets = 0:4))
))


OBS. You have to set the target. In the example all the 5 columns are aligned to "center" (targets = 0:4). Finally, note that column numbers start from 0, not from 1. That's a Javascript feature I suspect. But I am not an expert of JS.. Anyway this worked for me

Use targets="_all" to apply to all columns regardless of number of columns.

参考:https://stackoverflow.com/questi ... ent-in-dt-datatable
你这个问题很复杂,需要打赏,请点击 http://www.bio-info-trainee.com/donate 进行打赏,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|生信技能树    

GMT+8, 2019-3-26 19:06 , Processed in 0.043873 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.