【问题标题】:R DataTables do not search in column with html tagsR DataTables 不在带有 html 标签的列中搜索
【发布时间】: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


【解决方案1】:

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

【讨论】:

  • 太棒了!感谢您的帮助:)
猜你喜欢
  • 2016-12-29
  • 2019-06-21
  • 2018-06-28
  • 2017-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-06
  • 2016-09-25
相关资源
最近更新 更多