Dear datamods author,
I think it could be usefull to change the behaviour of reactive(NULL) for vars.
Indeed, when looking at the code filter_data_server will call create_filter to build the appropriate ui elements required for filtering data.
Default behaviour is to build filters for all data columns due to those lines since default vars argument value of filter_data_server is reactive(NULL) and NULL is 'corrected' to names(data).
For me this default behaviour is sane (if user did not pass value to vars ones may want to populate ui with all filters initially). However, I think it should be triggered by vars = reactive(names(data())) so as to liberate the use of reactive(NULL)
In my use case, vars is bound to a selectInput(...,multiple = TRUE) so that I can populate ui with the filters I only need.
Unfortunately, absence of selection send NULL which results in selecting everything which is kind of misleading/irrational
So, in create_filter, I would apply thoses changes to code:
if (!is.null(vars)) {
if (rlang::is_named(vars)) {
labels <- names(vars)
vars <- unname(unlist(vars))
} else {
labels <- vars
}
vars_display <- intersect(vars, names(data))
labels <- labels[vars %in% vars_display]
vars <- vars_display
# filters_id <- paste0("filter_", sample.int(1e9, length(vars)))
filters_id <- paste0("filter_", makeId(vars))
filters_id <- setNames(as.list(filters_id), vars)
filters_na_id <- setNames(as.list(paste0("na_", filters_id)), vars)
}
And in filter_data_server, this one to code
vars = reactive(names(data())
Dear datamods author,
I think it could be usefull to change the behaviour of
reactive(NULL)forvars.Indeed, when looking at the code filter_data_server will call create_filter to build the appropriate ui elements required for filtering data.
Default behaviour is to build filters for all data columns due to those lines since default
varsargument value of filter_data_server isreactive(NULL)andNULLis 'corrected' tonames(data).For me this default behaviour is sane (if user did not pass value to
varsones may want to populate ui with all filters initially). However, I think it should be triggered byvars = reactive(names(data()))so as to liberate the use ofreactive(NULL)In my use case,
varsis bound to a selectInput(...,multiple = TRUE) so that I can populate ui with the filters I only need.Unfortunately, absence of selection send
NULLwhich results in selecting everything which is kind of misleading/irrationalSo, in create_filter, I would apply thoses changes to code:
And in filter_data_server, this one to code