使用R中的DataTable软件包在表中对齐搜索栏和标题

发布于 2025-01-28 14:49:36 字数 645 浏览 1 评论 0原文

我已经在线搜索了广泛的搜索,但还没有使用可反应,可数据或格式的解决方案找到解决方案。我正在尝试创建一个表格标题与搜索栏对齐的表。在我看到的所有示例中,搜索栏都会创建它自己的行,因此您不能在同一行中拥有标题,因此它们永远都不会。 “表示例”

这是我到目前为止的代码:

    datatable(iris,
              options = list(dom = 'ft'),
              caption = htmltools::tags$caption(style = 'caption-side: top;
                                                text-align: left;
                                                color:black;
                                                font-size:24px;
                                                font-weight: bold;', "My title"))

I've searched extensively online and haven't found a solution for this using reactable, datatable, or formattable. I'm trying to create a table where the title of the table is aligned with the search bar. In all examples that I've seen, the search bar creates it's own row so you can't have the title in that same row so they're never even. Table example

Here is the code I have so far:

    datatable(iris,
              options = list(dom = 'ft'),
              caption = htmltools::tags$caption(style = 'caption-side: top;
                                                text-align: left;
                                                color:black;
                                                font-size:24px;
                                                font-weight: bold;', "My title"))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烙印 2025-02-04 14:49:36

谢谢@andrewjames!这帮助我开始了。如果使用闪亮的应用程序,请将以下代码添加到您的CSS文件中,以便将文本与DataTable的搜索栏对齐。请注意,标题和表是分开的。它不是DataTable中定义的标题。

#table-title {
  position: relative; top: 60px;
}

您的UI中的#table-title位置。例如:

fluidRow(column(width = 12, align = "left", div(id = "table-title", textOutput("table_title")))),

fluidRow(column(width = 12, align = "left", div(id = "my-table", dataTableOutput("my_table"))))

Thanks @andrewJames! This helped me get started. If using a Shiny app, add the following code to your css file so that the text is aligned with the search bar of a dataTable. Note that the title and table are separate. It is not a title defined in dataTable.

#table-title {
  position: relative; top: 60px;
}

Where #table-title is in your ui. For example:

fluidRow(column(width = 12, align = "left", div(id = "table-title", textOutput("table_title")))),

fluidRow(column(width = 12, align = "left", div(id = "my-table", dataTableOutput("my_table"))))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文