conditions

defines a custom set of filtering rules

array conditions;

Example

{
    view:"filter",
    mode:"number",
    field:"year",
    conditions:[
       "equal", "contains",
        // custom condition and input
        { id:"between", value:"Between", batch:"rangeslider", handler:function(a, b){
                return a >= b[0] && a <= b[1];
        }}
    ],
    inputs:["text", "rangeslider"]
    // ...
}

Related samples

Details

Each object in the conditions array contains these properties:

  • id - rule ID, should be unique and not coincide with any of the preset rules
  • value - text label for the rule
  • handler - comparison function with two parameters:
    • a - date filed value
    • b - input value
  • batch - name of the required input, which can be either one of the built-in ones or a custom one.

By default, full lists of conditions look as follows:

  • mode:"text"
conditions:["contains", "notContains", "equal", 
"notEqual", "beginsWith", "notBeginsWith", "endsWith", "notEndsWith" ]

All the text conditions use batch "text" for input.

  • mode: "date":
conditions:["greater", "less", "greaterOrEqual", 
"lessOrEqual", "equal", "notEqual", "between", "notBetween" ]

Date conditions use batches datepicker and daterangepicker (for "between" and "notBetween" rules) for input.

  • mode: "number"
conditions:["greater", "less", "greaterOrEqual", 
"lessOrEqual", "equal", "notEqual", "contains", "notContains" ]

All the number conditions use batch "text" for input.

See also
  • API
  • Articles
  • Back to top