简体   繁体   English

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

[英]R DataTables do not search in column with html tags

In my shiny app I render DataTable from DT package:在我闪亮的应用程序中,我从 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 )

Column number 4 is clickable and includes HTML tags eg第 4 列是可点击的,包括 HTML 标签,例如

<div id="44332211">33-ab-v4</div>

and I want to search in this column but NOT IN html tags .我想在此列中搜索但不是在 html 标签中 Reffering to this I added (as you can see above) to columnDefs :对此,我在columnDefs 中添加了(如您所见):

list(type = 'html', targets = 4)

but it does not work and DataTables search in whole cell value.但它不起作用,DataTables 在整个单元格值中搜索。 It should work like when I enter in search field: "44", DataTable should not find :它应该像我在搜索字段中输入时一样工作:“44”,DataTable不应该找到

<div id="44332211">33-ab-v4</div>

您好,您链接的页面中有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.

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

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