setValue

sets a value for Query Builder (fields and rules for filtering)

void setValue(object value);

Parameters

valueobjectthe object with fields and rules

Example

$$("querybuilder").setValue({
    query:{
        glue:"and",
        rules:[
            { key:"fname", value:"Alex", rule:"equal" },
            { 
                glue:"or",
                rules:[
                    { key:"age", value:90, rule:"less" },
                    { key:"age", value:10, rule:"greater" }
                ]
            }
        ]
    },
    fields:[
        { id:"fname", value:"First Name", type:"string" },
        { id:"lname", value:"Last Name", type:"string" }
    ]
});

Related samples

Details

There are several ways of setting the value for Query Builder. The value object can contain the following properties:

  • rules:
// setting only the rules object
$$("querybuilder").setValue({
    rules:[
        { key:"fname", value:"Alex", rule:"equal" },
        { 
            glue:"or",
            rules:[
                { key:"age", value:90, rule:"less" },
                { key:"age", value:10, rule:"greater" }
            ]
        }
    ]
});
  • glue:
// setting only the rules object
$$("querybuilder").setValue({
    glue:"and",
    rules:[
        { key:"fname", value:"Alex", rule:"equal" },
        { 
            glue:"or",
            rules:[
                { key:"age", value:90, rule:"less" },
                { key:"age", value:10, rule:"greater" }
            ]
        }
    ]
});
  • query:
$$("querybuilder").setValue({
    query:{
      glue:"and",
      rules:[
        { key:"fname", value:"Alex", rule:"equal" },
        { 
          glue:"or",
          rules:[
            { key:"age", value:90, rule:"less" },
            { key:"age", value:10, rule:"greater" }
          ]
        }
      ]
    }
});

You can also set fields with the setValue() methods by adding the fields property:

// setting only the fields array
$$("querybuilder").setValue({
    fields:[
        { id:"fname", value:"First Name", type:"string" },
        { id:"lname", value:"Last Name", type:"string" }
    ]
});
See also
Back to top