Members
-
<static, readonly> DEFAULTS :object
-
Description
Default configuration
Details
-
<static> Group :function
-
Details
-
<static, readonly> OPERATORS :object.<string, object>
-
Description
Default operators
Details
-
<static, readonly> regional :object.<string, object>
-
Description
Localized strings (see i18n/)
Details
-
<static> Rule :function
-
Details
-
<static, readonly> selectors :object.<string, string>
-
Description
CSS selectors for common components
Details
-
<static, readonly> templates :object.<string, string>
-
Description
Template strings (see template.js)
Details
-
<static> utils :object
-
Details
-
<readonly> $el :jQuery
-
Description
Element container
Details
-
<readonly> filters :Array.<QueryBuilder.Filter>
-
Description
List of filters
Details
-
<readonly> icons :object.<string, string>
-
Description
List of icons
Details
-
<readonly> lang :object
-
Description
Translations object
Details
-
<readonly> model :Model
-
Description
Internal model
Details
-
<readonly> operators :Array.<QueryBuilder.Operator>
-
Description
List of operators
Details
-
<readonly> plugins :object.<string, object>
-
Description
Plugins configuration
Details
-
<readonly> settings :object
-
Description
Configuration object
Details
-
<readonly> templates :object.<string, function()>
-
Description
List of templates
Details
Methods
-
addGroup( parent [, addRule [, data [, flags ] ] ] ) → {Group}
-
Description
Adds a new group
Parameters
Name Type Attributes Default Description parent
Group addRule
boolean <optional> true adds a default empty rule
data
object <optional> group custom data
flags
object <optional> flags to apply to the group
Returns
Fires
Details
-
addRule( parent [, data [, flags ] ] ) → {Rule}
-
Description
Adds a new rule
Parameters
Name Type Attributes Description parent
Group data
object <optional> rule custom data
flags
object <optional> flags to apply to the rule
Returns
Fires
Details
-
change( type, value ) → {*}
-
Description
Triggers an event on the builder container and returns the modified value
Parameters
Name Type Description type
string value
* Returns
Details
-
checkFilters( filters ) → {Array.<QueryBuilder.Filter>}
-
Description
Checks the configuration of each filter
Parameters
Name Type Description filters
Array.<QueryBuilder.Filter> Returns
Throws
Details
-
checkOperators( operators ) → {Array.<QueryBuilder.Operator>}
-
Description
Checks the configuration of each operator
Parameters
Name Type Description operators
Array.<QueryBuilder.Operator> Returns
Throws
Details
-
clear()
-
Description
Clears all rules and removes the root group
Fires
Details
-
clearErrors( [ node ] )
-
Description
Clears all errors markers
Parameters
Name Type Attributes Description node
Node <optional> default is root Group
Details
-
deleteGroup( group ) → {boolean}
-
Description
Tries to delete a group. The group is not deleted if at least one rule is flagged
no_delete
.Parameters
Name Type Description group
Group Returns
Fires
Details
-
deleteRule( rule ) → {boolean}
-
destroy()
-
Description
Destroys the builder
Fires
Details
-
getModel( [ target ] ) → {Node}
-
Description
Returns the model associated to a DOM object, or the root model
Parameters
Name Type Attributes Description target
jQuery <optional> Returns
Details
-
getRules( [ options ] ) → {object}
-
Description
Gets an object representing current rules
Parameters
Name Type Attributes Description options
object <optional> Name Type Attributes Default Description get_flags
boolean | string <optional> false export flags, true: only changes from default flags or 'all'
allow_invalid
boolean <optional> false returns rules even if they are invalid
skip_empty
boolean <optional> false remove rules that have no filter selected
Returns
Fires
Details
-
off( type [, cb ] ) → {QueryBuilder}
-
Description
Removes an event listener from the builder container
Parameters
Name Type Attributes Description type
string cb
function <optional> Returns
Details
-
on( type, cb ) → {QueryBuilder}
-
Description
Attaches an event listener on the builder container
Parameters
Name Type Description type
string cb
function Returns
Details
-
once( type, cb ) → {QueryBuilder}
-
Description
Attaches an event listener called once on the builder container
Parameters
Name Type Description type
string cb
function Returns
Details
-
reset()
-
Description
Clear all rules and resets the root group
Fires
Details
-
setOptions( options )
-
Description
Modifies the builder configuration.
Only options defined in QueryBuilder.modifiable_options are modifiableParameters
Name Type Description options
object Details
-
setRoot( [ addRule [, data [, flags ] ] ] ) → {Group}
-
Description
Creates the root group
Parameters
Name Type Attributes Default Description addRule
boolean <optional> true adds a default empty rule
data
object <optional> group custom data
flags
object <optional> flags to apply to the group
Returns
Fires
Details
-
setRules( data [, options ] )
-
Description
Sets rules from object
Parameters
Name Type Attributes Description data
object options
object <optional> Name Type Attributes Default Description allow_invalid
boolean <optional> false silent-fail if the data are invalid
Fires
Throws
Details
-
translate( [ category ], key ) → {string}
-
Description
Translate a label either by looking in the
lang
object or in itself if it's an object where keys are language codesParameters
Name Type Attributes Description category
string <optional> key
string | object Returns
Fires
Details
-
trigger( type ) → {$.Event}
-
Description
Triggers an event on the builder container
Parameters
Name Type Description type
string Returns
Details
-
validate( [ options ] ) → {boolean}
-
Description
Validates the whole builder
Parameters
Name Type Attributes Description options
object <optional> Name Type Attributes Default Description skip_empty
boolean <optional> false skips validating rules that have no filter selected
Returns
Fires
Details
-
validateValue( rule, value ) → {array|boolean}
-
Description
Performs value validation
Parameters
Name Type Description rule
Rule value
string | Array.<string> Returns
Fires
Details
Type Definitions
-
Filter
-
Description
Details
-
Operator
-
Description
Details
Events
-
changer:displayError
-
Description
Modifies an error message before display
Parameters
Name Type Description errorMessage
string the error message (translated and formatted)
error
array the raw error array (error code and optional arguments)
node
Node Returns
Details
-
changer:getDefaultFilter
-
Description
Modifies the default filter for a rule
Parameters
Name Type Description filter
QueryBuilder.Filter rule
Rule Returns
Details
-
changer:getGroupTemplate
-
Description
Modifies the raw HTML of a group
Parameters
Name Type Description html
string level
int Returns
Details
-
changer:getOperators
-
Description
Modifies the operators available for a filter
Parameters
Name Type Description operators
Array.<QueryBuilder.Operator> filter
QueryBuilder.Filter Returns
Details
-
changer:getRuleFilters
-
Description
Modifies the list a filters available for a rule
Parameters
Name Type Description filters
Array.<QueryBuilder.Filter> rule
Rule Returns
Details
-
changer:getRuleFilterSelect
-
Description
Modifies the raw HTML of the rule's filter dropdown
Parameters
Name Type Description html
string rule
Rule filters
Array.<QueryBuilder.Filter> Returns
Details
-
changer:getRuleInput
-
Description
Modifies the raw HTML of the rule's input
Parameters
Name Type Description html
string rule
Rule name
string the name that the input must have
Returns
Details
-
changer:getRuleOperatorSelect
-
Description
Modifies the raw HTML of the rule's operator dropdown
Parameters
Name Type Description html
string rule
Rule operators
Array.<QueryBuilder.Operator> Returns
Details
-
changer:getRules
-
Description
Modifies the result of the
QueryBuilder#getRules
methodParameters
Name Type Description json
object Returns
Details
-
changer:getRuleTemplate
-
Description
Modifies the raw HTML of a rule
Parameters
Name Type Description html
string Returns
Details
-
changer:getRuleValue
-
Description
Modifies the rule's value grabbed from the DOM
Parameters
Name Type Description value
* rule
Rule Returns
Details
-
changer:getRuleValueSelect
-
Description
Modifies the raw HTML of the rule's value dropdown (in case of a "select filter)
Parameters
Name Type Description html
string string}
name
rule
Rule Returns
Details
-
changer:groupToJson
-
Description
Modifies the JSON generated from a Group object
Parameters
Name Type Description json
object group
Group Returns
Details
-
changer:jsonToGroup
-
Description
Modifies the Group object generated from the JSON
Parameters
Name Type Description group
Group json
object Returns
Details
-
changer:jsonToRule
-
Description
Modifies the Rule object generated from the JSON
Parameters
Name Type Description rule
Rule json
object Returns
Details
-
changer:parseGroupFlags
-
Description
Modifies the consolidated group's flags
Parameters
Name Type Description flags
object group
object not a Group object
Returns
Details
-
changer:parseRuleFlags
-
Description
Modifies the consolidated rule's flags
Parameters
Name Type Description flags
object rule
object not a Rule object
Returns
Details
-
changer:ruleToJson
-
Description
Modifies the JSON generated from a Rule object
Parameters
Name Type Description json
object rule
Rule Returns
Details
-
changer:setRules
-
Description
Modifies data before the
QueryBuilder#setRules
methodParameters
Name Type Description json
object options
object Returns
Details
-
changer:translate
-
Description
Modifies the translated label
Parameters
Name Type Attributes Description translation
string key
string | object category
string <optional> Returns
Details
-
changer:validate
-
Description
Modifies the result of the
QueryBuilder#validate
methodParameters
Name Type Description valid
boolean Returns
Details
-
changer:validateValue
-
Description
Modifies the result of the rule validation method
Parameters
Name Type Description result
array | boolean true or an error array
value
* rule
Rule Returns
Details
-
afterAddGroup
-
afterAddRule
-
afterApplyGroupFlags
-
Description
After group's flags has been applied
Parameters
Name Type Description group
Group Details
-
afterApplyRuleFlags
-
afterClear
-
Description
After the
QueryBuilder#clear
methodDetails
-
afterCreateRuleFilters
-
Description
After creating the dropdown for filters
Parameters
Name Type Description rule
Rule Details
-
afterCreateRuleInput
-
Description
After creating the input for a rule and initializing optional plugin
Parameters
Name Type Description rule
Rule Details
-
afterCreateRuleOperators
-
Description
After creating the dropdown for operators
Parameters
Name Type Description rule
Rule operators
Array.<QueryBuilder.Operator> allowed operators for this rule
Details
-
afterDeleteGroup
-
Description
Just after deleting a group
Details
-
afterDeleteRule
-
Description
Just after deleting a rule
Details
-
afterInit
-
Description
When the initilization is done, just before creating the root group
Details
-
afterReset
-
Description
After the
QueryBuilder#reset
methodDetails
-
afterSetRules
-
Description
After the
QueryBuilder#setRules
methodDetails
-
afterUpdateGroupCondition
-
Description
After the group condition has been modified
Parameters
Name Type Description group
Group previousCondition
object Details
-
afterUpdateRuleFilter
-
Description
After the filter has been updated and the operators and input re-created
Parameters
Name Type Description rule
Rule previousFilter
object Details
-
afterUpdateRuleOperator
-
Description
After the operator has been updated and the input optionally re-created
Parameters
Name Type Description rule
Rule previousOperator
object Details
-
afterUpdateRuleValue
-
Description
After the rule value has been modified
Parameters
Name Type Description rule
Rule previousValue
* Details
-
beforeAddGroup
-
Description
Just before adding a group, can be prevented.
Parameters
Name Type Description parent
Group addRule
boolean if an empty rule will be added in the group
level
int nesting level of the group, 1 is the root group
Details
-
beforeAddRule
-
Description
Just before adding a rule, can be prevented
Parameters
Name Type Description parent
Group Details
-
beforeClear
-
Description
Before the
QueryBuilder#clear
method, can be preventedDetails
-
beforeDeleteGroup
-
Description
Just before deleting a group, can be prevented
Parameters
Name Type Description parent
Group Details
-
beforeDeleteRule
-
Description
Just before deleting a rule, can be prevented
Parameters
Name Type Description rule
Rule Details
-
beforeDestroy
-
Description
Before the
QueryBuilder#destroy
methodDetails
-
beforeReset
-
Description
Before the
QueryBuilder#reset
method, can be preventedDetails
-
rulesChanged
-
Description
After any change in the rules
Details
-
validationError
-
Description
Fired when a validation error occurred, can be prevented
Parameters
Name Type Description node
Node error
string value
* Details