简体   繁体   English

如何重命名 R 中 DT 数据表的 in 过滤器的占位符?

[英]How can I rename the placeholder of in filter of a DT datatable in R?

library(DT)
data <- data.frame("Hi" = c("One","Two"), "Something" = c("A", "B"))
datatable(data, filter = 'top')

Translating a DT::datatable is nicely documented here .翻译 DT::datatable 很好地记录在这里 But, I am having trouble translating the placeholder on filter showing "ALL" in the example above.但是,我在翻译上面示例中显示“ALL”的过滤器上的占位符时遇到了问题。 Does anyone have an idea how to change this?有谁知道如何改变这个?

It's not pretty, but until they enable this in their API, you could always clean up with javascript afterwards:这并不漂亮,但在他们在 API 中启用此功能之前,您可以随时使用 javascript 进行清理:

library(DT)
data <- data.frame("Hi" = c("One","Two"), "Something" = c("A", "B"))
datatable(
    data, filter = 'top',
    callback=JS('$(\'div.has-feedback input[type="search"]\').attr( "placeholder", "Alles" )')
)

Looks like this:看起来像这样:

改变占位符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM