R datatable: hide the search field for individual columns

I would like to enable column search, but disable it for specific columns.

Here is what I need https://rstudio.imtqy.com/DT/009-searchable.html but I would like to hide unused fields.

How to do it?

+3
source share
1 answer

You use CSS with a search selector disabled to hide them.

Here is an example in a brilliant application:

 library(shiny) shinyApp( ui = fluidPage(tags$head(tags$style( HTML("input[type='search']:disabled {visibility:hidden}") )), DT::dataTableOutput('tbl')), server = function(input, output) { iris2 = head(iris, 10) output$tbl = DT::renderDataTable(datatable( iris2, filter = 'top', options = list(columnDefs = list(list( targets = c(1, 3), searchable = FALSE )), pageLength = 5) )) } ) 
+7
source

Source: https://habr.com/ru/post/1245238/


All Articles