我正在尝试删除闪亮数据表中的标题行,有谁知道是否有这样做的选项?
最小的例子:
#SERVER.R
output$myTable <- renderDataTable({
datatable(dataset, rownames = FALSE, selection = 'none', options = list(dom = 't'))
})
#UI.R
dataTableOutput('myTable')
只需添加colnames = NULL
到您的datatable()
datatable(mtcars, rownames = FALSE,colnames=NULL, selection = 'none', options = list(dom = 't'))
看?datatable
塞巴斯蒂安在 15 年 10 月 28 日的回答对我来说不起作用renderDataTable(datatable(...))
。使用colnames = NULL
insidedatatable(...)
删除了表中的所有数据。我不得不使用colnames = ""
删除表头。
Adding colnames = NULL
no longer works and it renders an empty table. You can use headerCallBack
option to add a css that hides the header row to achieve this.
headerCallback <- c(
"function(thead, data, start, end, display){",
" $('th', thead).css('display', 'none');",
"}"
)
datatable(mtcars,
rownames = FALSE,
colnames=NULL,
selection = 'none',
options = list(
dom = 't',
headerCallback = JS(headerCallback)
)
)