queryFilter.Rd
Filters are responsible for defining available options for providing field-rules in the interface. With filters you may decide what operators should be available for the field, what possible operator-values can be chosen or even customize what kind of input controllers should be used for that goal.
queryFilter(
id,
field,
label,
optgroup,
type,
input,
values,
value_separator,
default_value,
input_event,
size,
rows,
multiple,
placeholder,
vertical,
validation,
operators,
default_operator,
plugin,
plugin_config,
data,
valueSetter,
valueGetter,
unique
)
Character string (required). Unique identifier of the filter.
Character string (equals `id` when missing). Field used by the filter, multiple filters can use the same field. The provided field wiil be used in the returned query.
Character string (equals `field` when missing). Label used to display the field.
Fields with the same `optgroup` will be presented within a separate group in the fields dropdown. If skipped, the field will be not listed in any of the groups, but presented independently.
Character string (required). Type of the field being an R class. The argument determines default configuration for the field input controllers. Available types are 'character', 'factor', 'integer', 'numeric', 'POSIXct', 'Date' and 'logical'.
Character string or JS function. Type of input used. Available types are 'text', 'number', 'textarea', 'radio', 'checkbox' and 'select'. It can also be a JS function which returns the HTML of the said input, this function takes 2 parameters:
rulethe Rule object
input_namethe name of the input
In order to define it, create the function definition as character string and pass it to js.
When skipped, the default input will be used based on the provided type
.
Vector of possible values. Required for limited selection inputs (e.g. 'radio', 'checkbox', 'select').
Character string. Used the split the provided value when a 'text' input is used with an operator allowing multiple values ('in' for example). When skipped, the provided input will be used as a bare value. Needs to be set, when multiple values needs to be provided for 'text' and 'textarea' inputs.
Default operator value.
(advanced) Character string ('change' by default). Space separated list of DOM events which the builder should listen to detect value changes.
Integer. Only for 'text' and 'textarea' inputs: horizontal size of the input.
Integer. Only for 'textarea' inputs: vertical size of the input.
Logical (`FALSE` default). Set to `TRUE` if value input controller should accept multiple values. Please make sure the corresponding operators allow to take multiple values to make it work, see mapOperator.
Character string Only for 'text' and 'textarea' inputs: placeholder to display inside the input.
Logical (FALSE default). Only for 'radio' and 'checkbox' inputs: display inputs vertically not horizontally.
List of options for rule validation. See vignette("validation")
.
Character vector of operators types to use for this filter. When skipped the filter will use all applicable operators. See listMappedOperators.
Character string. Name of the operator that should be used by default
when defining new rules.
When skipped the first value from operators
is used.
(advanced) Name of a jQuery plugin to apply on the input and plugin configuration. See https://querybuilder.js.org/demo.html#widgets.
List. Additional data that will be added to the returned query - `input` element returned by queryBuilderInput. Use this to store any functional data you need.
(advanced) JS function used to set the input(s) value. If provided the default function is not run. The function takes 2 parameters:
rulethe Rule object
value
In order to define it, create the function definition as character string and pass it to js.
(advanced) function Function used to get the input(s) value. If provided the default function is not run. It takes 1 parameter:
rulethe Rule object
In order to define it, create the function definition as character string and pass it to js.
Allow to use the filter only once. Can be `FALSE/TRUE` or 'group' to allow using filter once per group. In order to make it work please enable 'unique-filter' plugin (`plugin = list("unique-filter")`) for queryBuilderInput.
ui <- shiny::fluidPage(
queryBuilderInput(
"qb",
filters = list(
queryFilter(
"Species", type = "character", operators = c("in", "equal"),
values = levels(iris$Species), multiple = TRUE, input = "text", value_separator = ";"
),
queryFilter(
"Sepal.Length", type = "numeric", values = range(iris$Sepal.Length),
validation = list(min = 4.3, max = 7.9, step = 0.1)
)
)
),
shiny::verbatimTextOutput("expr")
)
server <- function(input, output, session) {}
if (interactive()) {
shiny::runApp(ui, server)
}