Cannot disable DT Column Filter Shiny Server Pro

845 views
Skip to first unread message

Logan Meltabarger

unread,
Oct 6, 2015, 9:02:12 PM10/6/15
to Shiny - Web Framework for R
I want to disable a column filter for the second column of my datatable.

I have attempted to disable it via many different versions of this: "columnDefs = list(list(targets = c(1),searchable = FALSE)),"

However, it never changes any of the column filters. I can, and have, disabled the global filter but cannot disable the second column filter. I want to keep the other column filters on top.

I have also tried disabling scroller with no avail.

I would also like to change "All" in the other column filters to some different text, but that is a smaller issue.



Any help is appreciated.

Below is the code for my datatable using DT-1.0 on Shiny Server Pro.

datatable(finalDataset,                     #create dataTable using the finalDataset
                             extensions = 'Scroller',          #use the scroller extension for better table viewing
                             filter = 'top',                   #add filters at the bottom of the page
                             rownames = FALSE,
                             selection="none",                 #turn off row selection
                             options = list(order = list(list(1, 'desc')), #order entries by newest to oldest date
                             searching = FALSE,
                             language = list(search = 'Keyword Search:'), #change title of search bar to "Keyword Search"
                             searchDelay = 1000,               #add delay to limit calls on large datasets
                             deferRender = TRUE,               #increase performance by only rendering what is on screen
                             scrollY = 300,                    #the height of the scroll table enabled by the Scroller extension
                             scrollCollapse = TRUE,            #allows the scroll window to shrink to dataset size if smaller than scrollY
                             columnDefs = list(list(targets = c(1),searchable = FALSE)),
                             autowidth = TRUE,                 #autowidth the other columns
                             searchHighlight=TRUE,             #highlight the keywords in the searches. futher customization in css files
                             lengthMenu = c(5,15,25,100),         #options of how many results are initially returned
                             pageLength = 15,                  #default length of the above options
                             server = TRUE                     #enable server side processing for better performance
                             ))

Thanks,
Logan
Auto Generated Inline Image 1

Yihui Xie

unread,
Oct 6, 2015, 9:22:54 PM10/6/15
to Logan Meltabarger, Shiny - Web Framework for R
Sorry, but this feature is only available in the current development
version of DT: https://github.com/rstudio/DT

Regards,
Yihui

On Tue, Oct 6, 2015 at 8:02 PM, Logan Meltabarger
<lrmelt...@gmail.com> wrote:
>
> I want to disable a column filter for the second column of my datatable.
>
> I have attempted to disable it via many different versions of this: "columnDefs = list(list(targets = c(1),searchable = FALSE)),"
>
> However, it never changes any of the column filters. I can, and have, disabled the global filter but cannot disable the second column filter. I want to keep the other column filters on top.
>
> I have also tried disabling scroller with no avail.
>
> I would also like to change "All" in the other column filters to some different text, but that is a smaller issue.
>
>
>

Logan Meltabarger

unread,
Oct 6, 2015, 9:36:00 PM10/6/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
Great, so I am still trying to get the development version install from behind my firewalls.

I used R CMD INSTALL and still received errors:

[sas@es0p776p Rpacks]$ R CMD INSTALL -l /usr/lib64/R/library/ DT_0.1.39.tar.gz
   Welcome to R!
Error in rawToChar(block[seq_len(ns)]) :
  embedded nul in string: '\037\x8b\b\0\0\0\0\0\0\003\xec\xbd\a`\\\xc5\xf18\f$4\x91\xd0{\002y>ۺ;\xeb\xe9tE\xf5\xcegG\u0376\x8c$ے\\dY\xb1\xdf\u077d\xd3=\xe9\x9a\xef\u0769X\022\xe4G\xef\035\x82\x89I!\xf4\x90\xd0;\x84NB\r\x84^B \xa1$\004H\002\t\t\t\x81ofw_\xbdw\xbas\xc1\x90\xef'
[sas@es0p776p Rpacks]$ R CMD INSTALL DT_0.1.39.tar.gz
   Welcome to R!
Error in rawToChar(block[seq_len(ns)]) :
  embedded nul in string: '\037\x8b\b\0\0\0\0\0\0\003\xec\xbd\a`\\\xc5\xf18\f$4\x91\xd0{\002y>ۺ;\xeb\xe9tE\xf5\xcegG\u0376\x8c$ے\\dY\xb1\xdf\u077d\xd3=\xe9\x9a\xef\u0769X\022\xe4G\xef\035\x82\x89I!\xf4\x90\xd0;\x84NB\r\x84^B \xa1$\004H\002\t\t\t\x81ofw_\xbdw\xbas\xc1\x90\xef'

Any ideas?

I am running RHEL5.

Thanks,
Logan

Yihui Xie

unread,
Oct 6, 2015, 10:00:36 PM10/6/15
to Logan Meltabarger, Shiny - Web Framework for R
What is your R version? I also wonder if the source package you
downloaded was actually corrupted due to the firewall. It should be
244330 bytes, and here is its MD5 sum:

$ md5 Downloads/DT_0.1.39.tar.gz
MD5 (Downloads/DT_0.1.39.tar.gz) = 2946bd26150fc381611b2dbaef7b852d

Regards,
Yihui

Logan Meltabarger

unread,
Oct 6, 2015, 10:32:18 PM10/6/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
I downloaded the package on a different machine and transferred it over...so the most recent dev version is installed. Thanks!

However, I still have the same exact issue as before using "columnDefs = list(list(targets = c(1),searchable = FALSE))," while all my columns remain searchable.

Thoughts?

Logan

Yihui Xie

unread,
Oct 6, 2015, 10:42:53 PM10/6/15
to Logan Meltabarger, Shiny - Web Framework for R
That is odd. Apparently it works here:
http://rstudio.github.io/DT/009-searchable.html

Are you sure you installed the dev version to the system library
(under /usr/)? You can open R and sapply(.libPaths(), list.files) to
see if you have multiple copies of DT installed in different
libraries. I think you also need to restart the R session after
installing the dev version of DT (e.g. via touch restart.txt).

Regards,
Yihui

Logan Meltabarger

unread,
Oct 6, 2015, 11:35:52 PM10/6/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
I restarted the process then got the error where DT now requires Shiny 12.2...so I updated Shiny and we are making progress.

Now I cannot use the desired column filter...is there a way I can make the filter box disappear altogether? Also, where can we change the default text of "All" in these boxes? I have been combing through all the bootstrap.css and cannot locate the proper place.



Thanks!

Logan

Auto Generated Inline Image 1

Logan Meltabarger

unread,
Oct 6, 2015, 11:40:06 PM10/6/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
Also, when I use the column filters it only highlights the input...it is not filtering the table down to the input in the filter box.

Yihui Xie

unread,
Oct 6, 2015, 11:46:35 PM10/6/15
to Logan Meltabarger, Shiny - Web Framework for R
On Tue, Oct 6, 2015 at 10:40 PM, Logan Meltabarger
<lrmelt...@gmail.com> wrote:
> Also, when I use the column filters it only highlights the input...it is not
> filtering the table down to the input in the filter box.

This should not happen. Can you provide a minimal reproducible
example? Are there any errors in the JavaScript console?

>
> On Tuesday, October 6, 2015 at 10:35:52 PM UTC-5, Logan Meltabarger wrote:
>>
>> I restarted the process then got the error where DT now requires Shiny
>> 12.2...so I updated Shiny and we are making progress.
>>
>> Now I cannot use the desired column filter...is there a way I can make the
>> filter box disappear altogether? Also, where can we change the default text
>> of "All" in these boxes? I have been combing through all the bootstrap.css
>> and cannot locate the proper place.

Currently there isn't a straightforward way to make the filter box
disappear, nor is there an option to control the placeholder "All". I
guess both can be achieved via JavaScript, though.

>>
>>
>>
>> Thanks!
>>
>> Logan

Logan Meltabarger

unread,
Oct 7, 2015, 12:04:16 AM10/7/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
Here is an example: I typed "ev" in the column filter and it highlighted all the "ev"s but there are several rows that do not have "ev" in them that remain.



Here is my datatable code:

 finalDataset <- deidentified[,c("Source","Date","Feedback")] #create dataset as subset of deidentified dataset with 3 columns
                   brks <- unique(finalDataset$Source)
                   clrs <- pal(length(unique(finalDataset$Source)))

                   datatable(finalDataset,                     #create dataTable using the finalDataset
                             extensions = 'Scroller',          #use the scroller extension for better table viewing
                             filter = 'top',                   #add filters at the bottom of the page
                             rownames = FALSE,
                             selection="none",                 #turn off row selection
                             options = list(order = list(list(1, 'desc')), #order entries by newest to oldest date
                             searching = FALSE,                #disable global search                         
                             deferRender = TRUE,               #increase performance by only rendering what is on screen
                             scrollY = 300,                    #the height of the scroll table enabled by the Scroller extension
                             scrollCollapse = TRUE,            #allows the scroll window to shrink to dataset size if smaller than scrollY
                             columnDefs = list(list(width = '125px', targets = c(0)),list(targets = c(1),searchable = FALSE)), #sets the width of the Source column

                             autowidth = TRUE,                 #autowidth the other columns
                             searchHighlight=TRUE,             #highlight the keywords in the searches. futher customization in css files
                             lengthMenu = c(15,50,100),         #options of how many results are initially returned

                             pageLength = 15,                  #default length of the above options
                             server = TRUE                     #enable server side processing for better performance
                             )) %>% formatStyle("Source",fontWeight = 'bold',color=styleEqual(brks,clrs)) #add colors to the different Sources

When I use the global search, everything filters correctly.
 

Auto Generated Inline Image 1

Logan Meltabarger

unread,
Oct 7, 2015, 5:19:51 PM10/7/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
I found the issue/bug...if "searching" is set to FALSE (disabling global search) then the column filters do not actually filter. When it is set to TRUE (or default) then the column filters work.
I was able to get around it by using CSS to hide the global search box while keeping "searching" set to TRUE. I was also able to hide my disabled search boxes by using CSS.

The last thing I want to do is change the default "placeholder" text that appears in the search boxes.
I have written a jquery to do this swap for me: "document.querySelector("td:nth-child(3) .has-feedback .form-control").setAttribute("placeholder","Keyword Search")" and placed it in a .js file in my "www" directory.
I am calling it in my ui.R with this: "mainPanel(bsAlert("alert"), tags$head(tags$script("placeholder-change.js"))"...but it is not changing the value. I wanted to do this with shinyjs, but my system will not allow me to install the proper prereqs.

Any thoughts on how to change the placeholder value?

Thanks,
Logan

Yihui Xie

unread,
Oct 14, 2015, 11:32:35 PM10/14/15
to Logan Meltabarger, Shiny - Web Framework for R
I think the problem is that the script was executed too early --
before the DataTable was actually initialized. The more proper place
to execute it is through the `callback` argument of datatable():
http://rstudio.github.io/DT/ (Section 2.8, or ?DT::datatable)

Regards,
Yihui

Logan Meltabarger

unread,
Oct 28, 2015, 10:23:39 AM10/28/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
That still did not work....however, I implemented the work around in a previous post for the main issue so I will mark this as completed.
Reply all
Reply to author
Forward
0 new messages