Available only in PRO Edition
This article explores how the filter rules are formed and the extended filtering logic of the Query Builder works.
When you initialize Query Builder, it doesn't have any filter rules specified. So the initial rules object contains:
{
"glue": "and",
"rules": []
}
After the user has added a rule, a new object is added into the rules array:
{
"glue": "and",
"rules": [
{
"key": "fname",
"rule": "begins with",
"value": "Alex"
}
]
}
Thus, a filter rule consists of three fields which are specified by the following properties:
The contents of the "key" field are defined by the related field object of the Query Builder.
The key property of the rule object corresponds to the id of the field object.
[
// rules
{
glue:"and",
rules:[
{ key:"fname", value:"Alex", rule:"equal" }
...
]
},
// fields
[
{ id:"fname", value:"First Name", type:"string" }
...
]
]
The contents of the "rule" field are formed by the values of the name properties of all filter objects.
The rule property of the rule object corresponds to the id of the filter object.
// rules object
{
glue:"and",
rules:[
{
"key": "age",
"value": 90,
"rule": "less"
},
]
},
// filter object
{
id: "less",
name: "less",
fn: function(a, b) { return a < b; },
type: "number"
}
The filter types shown as selection options of the "rule" field are defined by the type of the field:
Read more about filters in the related article.
The "value" field is intended for entering a value to compare a dataset item with for filtering by the corresponding rule. The type of the entered value depends on the type of the field.
The type of the input for entering a value is defined by the filter rule and the type of the input field. There are 4 types of inputs:
The value of the RangeSlider is set as an array of arrays, where the first array defines the currently selected range and the second one defines the min and max values. For example:
{
"key": "age",
"rule": "between",
"value": [[ 27,62],[0,100]]
}