R DataTables 不在带有 html 标签的列中搜索

R DataTables do not search in column with html tags

在我闪亮的应用程序中,我从 DT 包中渲染数据表:

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>

你好在页面中你link有 Please note that if you are using server-side processing (serverSide) this option has no effect since the ordering and search actions are performed by a server-side script.