gpt4 book ai didi

javascript - 更改数据表中的列过滤器 "All"标签

转载 作者:行者123 更新时间:2023-12-04 08:43:35 25 4
gpt4 key购买 nike

我试图将出现在数据表(即“全部”)中的默认标签更改为其他内容,例如:"Sélectionner" .
这是我的代码:

library(DT)   

datatable(head(diamonds),
rownames = F,
class = 'cell-border stripe',
extensions = c('Buttons', 'Select', 'SearchPanes', 'FixedColumns'),
selection = 'none',
filter = 'top',
options = list(autoWidth = T,
dom = 'Bfrt',
pageLength = length(head(diamonds)),
columnDefs = list(list(width = '150px', targets = list(1,2,3)),
list(width = '300px', targets = list(5))),
searchHighlight = TRUE,
buttons = c('csv', 'excel', 'pdf'),
scrollY=600,
scrollX=300,
scroller = TRUE,
deferRender = TRUE,
scrollCollapse = F,
oLanguage = list("sSearch" = "Rechercher :",
"sZeroRecords" = "Aucun résultat disponible"),
oTable = list("aoSearchCols" = "Aloooo")))
enter image description here
我尝试了不同的选项,例如用 aoColumns、sSearchCols、aoSearchCols 和 aoColumnDefs 替换 oTable,但似乎没有任何效果。

最佳答案

使用回调( related GitHub issue 281 ):

library(DT)

datatable(head(diamonds),
filter = 'top',
callback = JS("$(\"input[type='search']\").attr('placeholder','xyz');")
)
enter image description here
或者有点hack,将数据表对象分配给变量,然后gsub:
myDT <- datatable(head(diamonds),
filter = 'top')

myDT[["x"]][["filterHTML"]] <- gsub('placeholder=\"All\"', 'placeholder=\"xyz\"',
myDT[["x"]][["filterHTML"]])

myDT

关于javascript - 更改数据表中的列过滤器 "All"标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64443411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com