闪亮DT中桌子容器的动态数量
我在Shiny R中的DT有问题。 假设我们有下表:
我使用代码得到了它:
sketch = htmltools::withTags(
table(
class = 'display',
thead(
tr(
th(rowspan = 2, 'Name'),
th(colspan = 2, '2022-06-01'),
th(colspan = 2, '2022-06-02')
),
tr(
lapply(rep(c('Length', 'Width'), 2), th)
)
)
)
)
datatable(df, container = sketch, rownames = FALSE)
我希望能够自动动态管理容器数量。 虽然在元素中
lapply (rep (c ('Length', 'Width'), 2), th)
很简单,但通过用传递的参数替换2,我无法完全管理片段
tr (
th (rowspan = 2, 'Name'),
th (colspan = 2, '2022-06-01'),
th (colspan = 2, '2022-06-02')
)
以动态添加其他元素,即获得
tr (
th (rowspan = 2, 'Name'),
th (colspan = 2, '2022-06-01'),
th (colspan = 2, '2022-06-02'),
th (colspan = 2, '2022-06-03'),
th (colspan = 2, '2022-06-04'),
)
任何想法如何获得这种效果?非常感谢!
I have problem with my DT in shiny R.
suppose we have the following table:
I got it using the code:
sketch = htmltools::withTags(
table(
class = 'display',
thead(
tr(
th(rowspan = 2, 'Name'),
th(colspan = 2, '2022-06-01'),
th(colspan = 2, '2022-06-02')
),
tr(
lapply(rep(c('Length', 'Width'), 2), th)
)
)
)
)
datatable(df, container = sketch, rownames = FALSE)
I would like to be able to dynamically manage the number of containers automatically.
While in the element
lapply (rep (c ('Length', 'Width'), 2), th)
it's simple, by replacing 2 with the passed parameter, I can't manage the fragment completely
tr (
th (rowspan = 2, 'Name'),
th (colspan = 2, '2022-06-01'),
th (colspan = 2, '2022-06-02')
)
to dynamically add additional elements, i.e. obtain e.g.
tr (
th (rowspan = 2, 'Name'),
th (colspan = 2, '2022-06-01'),
th (colspan = 2, '2022-06-02'),
th (colspan = 2, '2022-06-03'),
th (colspan = 2, '2022-06-04'),
)
any ideas how to get this effect? Many Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样,如果我理解一个问题:
Like this, if I understand the question: