Skip to content

How to use the 'datepicker' plugin? #1

@paulvanoppen

Description

@paulvanoppen

Hi Yann-Aël,

I have been playing around with your R package queryBuildR. Thanks for putting the efforts in to build that. Very useful.

I would appreciate a bit of guideance. I am building a Shiny app that intends to apply the quiryBuildR to a dataframe. The data frame contains several columns of a Date (or if easier a POSIXct) class. For those columns, I would like the queryBuildR to show less, less or equal, greater and greater or equal filter options. In that way, I can apply filters relating to date ranges. I had a look at your getFiltersFromTable function and noted that columns of class ‘Date’ or “POSIXct’ are not supported. After some efffort I figuerd out how to adjust the filters to accommodate fro a date class.

Then I was interested to use the 'datepicker' plugin for columns of date or POSIXct class.
I had a look at the JQuery queryBuilder support pages and came up with the following code that should invoke the ‘datepicker’ plugin. However, this appears not to work. I either use the incorrect filter code or the plugin is not (yet) supported in your package.

I now built the following code in my own version of getFiltersFromTable:

MyGetFiltersFromTable <- function(data) {
  filters <- list()
  namesCol <- colnames(data)
  niceNames <- as.vector(sapply(namesCol,idToName))

  for (i in seq_along(namesCol)) {
    filterCol <-
      switch(        
RMA_issue_date = list(
          id = namesCol[i],
          label = niceNames[i],
          type = 'date',
          validation = list(
            format = 'MM/DD/YYYY'
            ),
          plugin = 'datepicker',
          plugin_config = list(
            format ='MM/DD/YYYY',
            todayBtn = 'linked',
            todayHighlight =TRUE,
            autoclose = TRUE
          ),
          operators = list(
            'equal','not_equal','less', 'less_or_equal', 'greater','greater_or_equal','between','in', 'not_in','is_null', 'is_not_null'
          )
        ),
…

I am not sufficiently familiar with javascript jQuery QueryBuilder to determine how to adjust the getFiltersFromTable function or how to install the plugin. Any suggestion are welcomed. Thanks.

Paul

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions