By default Query uses filtering rules depending on the field type that can be "text", "date" or "number".
Each field object has the following properties:
view:"query", fields: [
{
id: "first_name",
value: "First Name",
type: "text",
},
// other fields
]
As far as Query uses Filter under the hood, its filtering rules are the same.
You can restrict the number of filtering rules for a particular field by providing an array of conditions for this field:
var fields = [
{
id: "first_name", value: "First Name", type: "text",
conditions: ["equal", "contains"] // only 2 conditions
}
]
Furthermore, you can provide custom filtering rules in the conditions array. To do this, take the following steps:
1) Create an object and provide a custom condition in it:
Creating a custom condition
var maxLength = {
id: "max-length",
value: "Max Length",
batch: "text",
handler: (a, v) => a.length <= v,
};
The object contains 4 properties:
2) Add the conditions property (an array) and pass your custom condition there:
Providing custom conditions
var fields = [
{
id: "first_name",
value: "First Name",
type: "text",
conditions: ["equal", "contains", maxLength] // custom "maxLength" condition
}
]
Related sample: Query: Custom Conditions
Result should be the following:
You can also customize value format and define how the value will be displayed in the widget. To do that access the format property of a field and define a formatting function:
view: "query",
fields: [
{
id: "birthdate",
value: "Date of birth",
type: "date",
// long date representation
format: value => webix.i18n.longDateFormatStr(value),
}
]
Related sample: Query: Custom Format
Back to top