r Shiny:选择一行以开始显示数据表
下面有一个闪亮的应用程序,该应用使用DataTable
使用dt
。而不是让表从第1行开始显示,我想将表渲染使用用户选择的特定顶行(在此示例中使用Input $ startrow
)。
例如,如果用户在滑块中选择50,则表中显示的第一行是第50行,而不是第1行。
获得动态起始行的任何提示。
为了清楚地编辑:我不想将表子集划分,我想显示要在input $ startrow
中开始,但是用户可以上下滚动并仍然查看整个数据集(例如,>
忠实的
在此示例中)。
编辑2:似乎问题是displayStart
选项是我想要的,但是有一个已知错误截至5月21日,scroller
启动显示中间表。
library(shiny)
library(DT)
data("faithful")
ui <- fluidPage(
h2("Select the first row of the table to show"),
sliderInput(inputId="startRow",
label="Choose a row to start the datatable display",
min = 1,
max = 200,
value = 100,
step=5),
# show a datatable
h2("Show a table"),
dataTableOutput("table1")
)
server <- function(input, output) {
output$table1 <- renderDataTable({
# use input$startRow to begin the table display?
datatable(faithful,
extensions = "Scroller",
options = list(scrollY = 300,
scroller = TRUE))
})
}
# Run the application
shinyApp(ui = ui, server = server)
below there is a shiny app that renders a datatable
using DT
. Rather than have the table start the display at row 1 I'd like to have the table render with a specific top row selected by the user (using input$startRow
in this example).
E.g., if the user chose 50 in the slider the first row shown in the table would be row 50 rather than row 1.
Any tips for getting a dynamic starting row appreciated.
Edit for clarity: I do not want to subset the table, I want to display to begin at input$startRow
but the user could scroll up and down and still see the entire dataset (e.g., faithful
in this example).
Edit 2: It looks like the issue is that the displayStart
option is what I want but that there is a known bug as of May 21 with Scroller
starting the display mid table.
library(shiny)
library(DT)
data("faithful")
ui <- fluidPage(
h2("Select the first row of the table to show"),
sliderInput(inputId="startRow",
label="Choose a row to start the datatable display",
min = 1,
max = 200,
value = 100,
step=5),
# show a datatable
h2("Show a table"),
dataTableOutput("table1")
)
server <- function(input, output) {
output$table1 <- renderDataTable({
# use input$startRow to begin the table display?
datatable(faithful,
extensions = "Scroller",
options = list(scrollY = 300,
scroller = TRUE))
})
}
# Run the application
shinyApp(ui = ui, server = server)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
成功。跟随 link> link> link 评论。我能够使用
initcomplete
从input $ startrow
在行上启动表。这似乎有效。Success. Following the link in the comment. I was able to use
initComplete
to start the table on the row frominput$startRow
. This appears to work.是的,使用
输入$ startrow
开始表显示以生成所选表。Yes, use
input$startRow
to begin the table display to generate the selected table.