【发布时间】:2017-05-23 17:02:23
【问题描述】:
在我闪亮的应用程序中,我从 DT 包中渲染 DataTable:
DT::renderDataTable( {
datatable(
data = DT_frame,
selection = 'multiple', class = 'cell-border strip hover',
escape = FALSE, #po to, zeby dzialal: <a href=''></a>
rownames = TRUE,
filter = list(position = "top",
clear = F,
plain = T),
extensions = list(
# "FixedHeader" = NULL ,
# 'ColReorder' = NULL ,
'Buttons' = NULL
),
options = list(
scrollX = TRUE,
processing = T,
searchHighlight = TRUE,
search = list(regex = TRUE, caseInsensitive = T),
columnDefs = list(list(targets = cols2hide, visible = FALSE), list(type = 'html', targets = 4) ),
# aoColumnDefs = list(list(sType = "html", aTargets = 4 )),
# fixedHeader = TRUE,
# colReorder = TRUE,
dom = 'Blfrtip',
# dom legend
# p - NEXT/PREVIUS
# i - Showing 1 to 10 of 106 entries
# B - column visibility button
# l - show n entries list
buttons = c('colvis', 'csv')
)
) %>% formatStyle(columns = max_hash2_col_number, backgroundColor = '#CBFFB8') %>%
formatStyle(max_hash2_col_number, cursor = 'pointer') }, server = T )
第 4 列是可点击的,包括 HTML 标记,例如
<div id="44332211">33-ab-v4</div>
我想在此列中搜索但不在 html 标签中。参考this 我添加(如上所示)到columnDefs:
list(type = 'html', targets = 4)
但它不起作用,DataTables 在整个单元格值中搜索。它应该像我在搜索字段中输入时一样工作:“44”,DataTable 不应该找到:
<div id="44332211">33-ab-v4</div>
【问题讨论】:
-
这个问题解决了吗?我正在处理同样的问题,也许在发布接受的答案后的 2 年内出现了解决方案。
标签: html r datatables shiny dt