SNT*_*SNT 6 r datatables shiny
我在一个闪亮的应用程序中有一个数据表,我在其中进行分页以仅显示 15 行。但是我可以添加一个选项,用户可以使用分页或显示所有按钮一次查看 15 行,该按钮将显示带有滚动条的所有记录。
library(shiny)
library(DT)
library(shinyWidgets)
library(shiny)
shinyApp(
ui = navbarPage(
title = 'DataTable',
tabPanel('Display length', DT::dataTableOutput('ex2'))
),
server = function(input, output, session) {
output$ex2 <- DT::renderDataTable(
DT::datatable(
iris, options = list(
lengthMenu = list(c(5, 15, -1), c('5', '15', 'All')),
pageLength = 15
)
)
)
}
)
Run Code Online (Sandbox Code Playgroud)
这个怎么样,使用按钮扩展。我们定义了一个调用 javascript 函数的自定义按钮page.len(-1),其中-1表示所有行:
shinyApp(
ui = navbarPage(
title = 'DataTable',
tabPanel('Display length', DT::dataTableOutput('ex2'))
),
server = function(input, output, session) {
output$ex2 <- DT::renderDataTable(
DT::datatable(
iris,
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
lengthMenu = list(c(5, 15, -1), c('5', '15', 'All')),
pageLength = 15,
buttons = list(
list(
extend = "collection",
text = 'Show All',
action = DT::JS("function ( e, dt, node, config ) {
dt.page.len(-1);
dt.ajax.reload();
}")
)
)
)
)
)
}
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4483 次 |
| 最近记录: |