queryBuilderInput.Rd
Generate Shiny Query Widget
queryBuilderInput(
inputId,
filters,
rules = list(),
operators = NULL,
optgroups,
default_filter,
sort_filters = FALSE,
allow_groups = TRUE,
allow_rm_groups = TRUE,
allow_empty = TRUE,
display_errors = TRUE,
conditions = c("AND", "OR"),
default_condition = "AND",
inputs_separator = " , ",
display_empty_filter = TRUE,
select_placeholder = "------",
lang,
plugins,
allow_add_rules = TRUE,
allow_rm_rules = TRUE,
.queryBuilderConfig = queryBuilder::queryBuilderConfig
)
updateQueryBuilderInput(
session,
inputId,
rules,
filters,
allow_add_rules,
allow_rm_rules,
allow_groups,
allow_rm_groups
)
The input slot that will be used to access the value.
(required) List of available filters in the builder. See queryFilter.
Initial set of rules set with `queryBuilder` package. See queryGroup and queryRule. For `queryRule`, `shinyQueryBuilder` accepts an extra argument `flags`, that consists of four logical elements: `filter_readonly`, `operator_readonly`, `value_readonly` and `no_delete`. These options prevent from changing the rule inputs and removing the rule in the controller. For `queryGroup`, `shinyQueryBuilder` accepts an extra argument `flags`, that consists of four logical elements: `condition_readonly`, `no_add_rule`, `no_add_group` and `no_delete`. These options allow to disable corresponding group management options.
Vector of operator names that should be limited in the input.
Leave NULL
to allow all of the configured filters.
Named list. Configuration of labels for filters and operators. List names should consists of 'optgroup' ids, whereas values, the desired labels to be displayed.
Character string. The id of the default filter chosen for any new rule.
Set to `TRUE` to sort filters alphabetically.
Logical or integer. Number of allowed nested groups. TRUE for no limit.
Logical. Should removing groups be enabled.
Logical. No error will be thrown if the builder is entirely empty.
Logical (`TRUE`, default). When an error occurs on a rule, display an icon with a tooltip explaining the error.
Character vector. Array of available group conditions. In order to create custom condition check setQueryConditions.
Character string. Default active condition selected for each new group.
Character string that will be used to separate multiple input controllers for operator values (for operators with `nb_inputs > 1`). Default is ','.
Logical. Add an empty option with `select_placeholder` string to the filter dropdowns. If the empty filter is disabled and no default_filter is defined, the first filter will be loaded when adding a rule.
Character string. An option that can be chosen to select empty filter.
Nested named list providing language translations for selected controller labels. See https://github.com/mistic100/jQuery-QueryBuilder/blob/dev/src/i18n/en.json for the required structure, or load one of the existing files included at https://github.com/mistic100/jQuery-QueryBuilder/blob/dev/src/i18n.
List of plugins names used for the widget. See https://querybuilder.js.org/plugins.html.
Logical. Should adding new rules be enabled.
Logical. Should removing rules be enabled.
R6 object of class 'queryBuilderConfig' storing queryOperators. See query-operator.
Shiny session object.
ui <- shiny::fluidPage(
queryBuilderInput(
"qb",
filters = list(
queryFilter(
"Species", type = "character", operators = c("in", "equal"),
values = levels(iris$Species), multiple = TRUE,
optgroup = "char_fields"
),
queryFilter("Sepal.Length", type = "numeric", values = range(iris$Sepal.Length), optgroup = "num_fields")
),
rules = queryGroup(
condition = "AND",
queryRule("Species", "equal", "setosa", flags = list(no_delete = TRUE)),
queryRule("Sepal.Length", "between", c(5, 7))
),
optgroups = list(num_fields = "Numerical fields", char_fields = "Character fields")
),
shiny::verbatimTextOutput("expr")
)
server <- function(input, output, session) {}
if (interactive()) {
shiny::runApp(ui, server)
}