mistic100 / jQuery-QueryBuilder

jQuery plugin offering an interface to create complex queries
https://querybuilder.js.org
MIT License
1.68k stars 552 forks source link

Hierarchical structure #949

Open PisceanPurva opened 2 years ago

PisceanPurva commented 2 years ago

Hi , I wanted to create a hierarchy using this plugin, Right now what i saw, is it groups the rules together ,but they are not in any hierarchical structure. Can i customize this plugin, if so how?

{ "condition": "AND", "rules": [ { "id": "price", "field": "price", "type": "double", "input": "number", "operator": "less", "value": 10.25 }, { "condition": "OR", "rules": [ { "id": "category", "field": "category", "type": "integer", "input": "select", "operator": "equal", "value": 2 }, { "id": "price", "field": "price", "type": "double", "input": "number", "operator": "equal", "value": 1 } ] }, { "id": "name", "field": "name", "type": "string", "input": "text", "operator": "equal", "value": "Test" } ], "valid": true }

SO as per this eg: image

price, group(category & price) and name they all are in same level, but what if i want to define that group(category & price) inside the price(1st block) so that when i do get rules, i should get something like this.

Please help.

This is what i am expecting to create a json: { "condition": "AND", "rules": [ { "id": "price", "field": "price", "type": "double", "input": "number", "operator": "less", "value": 10.25, "rules": [ { "condition": "OR", "rules": [ { "id": "category", "field": "category", "type": "integer", "input": "select", "operator": "equal", "value": 2 }, { "id": "price", "field": "price", "type": "double", "input": "number", "operator": "equal", "value": 1 } ] } ] }, { "id": "name", "field": "name", "type": "string", "input": "text", "operator": "equal", "value": "Test", "rules": [] } ], "valid": true }