更改数据表中的列过滤器 "All" 标签
Change column filter "All" label in datatable
我正在尝试将 DataTable 中出现的默认标签(即“全部”)更改为其他内容,例如:"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")))
我尝试了不同的选项,例如将 oTable 替换为 aoColumns、sSearchCols、aoSearchCols 和 aoColumnDefs,但似乎没有任何效果。
使用回调 (related GitHub issue 281):
library(DT)
datatable(head(diamonds),
filter = 'top',
callback = JS("$(\"input[type='search']\").attr('placeholder','xyz');")
)
或者有点 hack,将 datatable 对象分配给变量,然后 gsub:
myDT <- datatable(head(diamonds),
filter = 'top')
myDT[["x"]][["filterHTML"]] <- gsub('placeholder=\"All\"', 'placeholder=\"xyz\"',
myDT[["x"]][["filterHTML"]])
myDT
我正在尝试将 DataTable 中出现的默认标签(即“全部”)更改为其他内容,例如:"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")))
我尝试了不同的选项,例如将 oTable 替换为 aoColumns、sSearchCols、aoSearchCols 和 aoColumnDefs,但似乎没有任何效果。
使用回调 (related GitHub issue 281):
library(DT)
datatable(head(diamonds),
filter = 'top',
callback = JS("$(\"input[type='search']\").attr('placeholder','xyz');")
)
或者有点 hack,将 datatable 对象分配给变量,然后 gsub:
myDT <- datatable(head(diamonds),
filter = 'top')
myDT[["x"]][["filterHTML"]] <- gsub('placeholder=\"All\"', 'placeholder=\"xyz\"',
myDT[["x"]][["filterHTML"]])
myDT