我该怎么创造 mouseover text
对于R闪亮数据表显示中的列名称。
我正在尝试为用户提供一些文本来理解列名。
我也检查了DT包,但我找不到解决方案。
我可以为列名创建标签,并在用户检查框时显示所有这些标签,这需要大量的空间,我不希望这样。
有小费吗?
我该怎么创造 mouseover text
对于R闪亮数据表显示中的列名称。
我正在尝试为用户提供一些文本来理解列名。
我也检查了DT包,但我找不到解决方案。
我可以为列名创建标签,并在用户检查框时显示所有这些标签,这需要大量的空间,我不希望这样。
有小费吗?
为了扩展我上面的评论,这里有一个例子,显示了我的意思 title
属性:
library(DT)
sketch = htmltools::withTags(table(
class = 'display',
thead(
tr(
th('', title = 'Row Names'),
th('Sepal.Length', title = 'The Sepal Length'),
th('Sepal.Width', title = 'The Sepal Width'),
th('Petal.Length', title = 'The Petal Length'),
th('Petal.Width', title = 'The Petal Width'),
th('Species', title = 'Iris Species')
)
)
))
datatable(iris, container = sketch)
这是另一种使用JavaScript(jQuery)添加的方法 title
属性:
library(DT)
datatable(iris, callback = JS("
var tips = ['Row Names', 'The Sepal Length', 'The Sepal Width',
'The Petal Length', 'The Petal Width'],
header = table.columns().header();
for (var i = 0; i < tips.length; i++) {
$(header[i]).attr('title', tips[i]);
}
"))
你可以用它完成 options
在里面 renderDataTable()
功能在闪亮。来自 文件 在闪亮的DT页面,这样的东西应该工作。
renderDataTable(head(iris, 20), options = list(
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).on({
mouseenter: function () {
//stuff to do on mouse enter
},
mouseleave: function () {
//stuff to do on mouse leave
}
});",
"}")
))