对于renderDataTable,在R中为DataTables使用TableTools
对于这个问题,我使用了下面的R Shining教程示例: 在本教程中运行代码将以以下URL呈现应用程序 我想知道的是,一旦呈现了该数据表,我们就可以使用R中renderDataTable()函数内置的功能对其进行搜索,但是是否可以使用renderDataTable()函数下载已过滤的数据 例如,如果在数据表搜索栏中键入“非常好”,则仅显示“剪切”字段中读取“非常好”的记录。然后我将如何下载该数据集 如何在代码中调用TableTools.js复制、打印、保存等按钮对于renderDataTable,在R中为DataTables使用TableTools,r,jquery-datatables,shiny,tabletools,R,Jquery Datatables,Shiny,Tabletools,对于这个问题,我使用了下面的R Shining教程示例: 在本教程中运行代码将以以下URL呈现应用程序 我想知道的是,一旦呈现了该数据表,我们就可以使用R中renderDataTable()函数内置的功能对其进行搜索,但是是否可以使用renderDataTable()函数下载已过滤的数据 例如,如果在数据表搜索栏中键入“非常好”,则仅显示“剪切”字段中读取“非常好”的记录。然后我将如何下载该数据集 如何在代码中调用TableTools.js复制、打印、保存等按钮 谢谢大家! 您需要链接到正确
谢谢大家! 您需要链接到正确的库版本。有关表1.9.4的数据链接,请访问。指向tabletools 2.1.5的链接
库(闪亮)
图书馆(GG2)
runApp(
列表(ui=basicPage)(
h1(“带TableTools的钻石数据表”),
标签列表(
singleton(标记$head(标记$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.datatables.min.js',type='text/javascript')),
singleton(标记$head(标记$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables tabletools/2.1.5/js/tabletools.min.js',type='text/javascript')),
singleton(标记$head(标记$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables tabletools/2.1.5/js/zerociplate.min.js',type='text/javascript')),
singleton(标记$head(标记$link(href='//cdnjs.cloudflare.com/ajax/libs/datatables tabletools/2.1.5/css/tabletools.min.css',rel='stylesheet',type='text/css')),
singleton(标记$script(HTML(“if(window.innerHeight<400)alert('Screen too small');”)))
),
dataTableOutput(“mytable”)
)
,服务器=功能(输入,输出){
输出$mytable=renderDataTable({
钻石[,1:6]
},选项=列表(
“sDom”=“Tlfrtip”,
“oTableTools”=列表(
“sSwfPath”=“cdnjs.cloudflare.com/ajax/libs/datatables tabletools/2.1.5/swf/copy_csv_xls.swf”,
“阿布顿”=列表(
“复制”,
“打印”,
列表(“sExtends”=“collection”,
“sbuttonext”=“保存”,
“桥台”=c(“csv”、“xls”)
)
)
)
)
)
})
)
我也对这项工作感兴趣。我在下面的url中看到了它,但没有成功地使它工作:
library(shiny)
library(ggplot2)
runApp(
list(ui = basicPage(
h1('Diamonds DataTable with TableTools'),
tagList(
singleton(tags$head(tags$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.dataTables.min.js',type='text/javascript'))),
singleton(tags$head(tags$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/TableTools.min.js',type='text/javascript'))),
singleton(tags$head(tags$script(src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/ZeroClipboard.min.js',type='text/javascript'))),
singleton(tags$head(tags$link(href='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/css/TableTools.min.css',rel='stylesheet',type='text/css'))),
singleton(tags$script(HTML("if (window.innerHeight < 400) alert('Screen too small');")))
),
dataTableOutput("mytable")
)
,server = function(input, output) {
output$mytable = renderDataTable({
diamonds[,1:6]
}, options = list(
"sDom" = 'T<"clear">lfrtip',
"oTableTools" = list(
"sSwfPath" = "//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/swf/copy_csv_xls.swf",
"aButtons" = list(
"copy",
"print",
list("sExtends" = "collection",
"sButtonText" = "Save",
"aButtons" = c("csv","xls")
)
)
)
)
)
})
)