R DataTables不使用html标记搜索列

时间:2017-01-09 12:18:32

标签: html r datatables shiny dt

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

getChildFragmentManager()

第4列是可点击的,包括HTML标签,例如

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 )

我想在此列中搜索但不是在HTML标签。感谢this我添加(如上所示) columnDefs

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

但它不起作用,DataTables搜索整个单元格值。它应该像我进入搜索字段时那样工作:“44”,DataTable 找不到

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

1 个答案:

答案 0 :(得分:1)

你好在你链接的页面中 body { min-width: 200px; max-width: 400px; width: calc(100% - 30px); }