Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to always use OR operator between groups #689

Closed
Pryanic opened this issue Apr 30, 2018 · 7 comments
Closed

How to always use OR operator between groups #689

Pryanic opened this issue Apr 30, 2018 · 7 comments
Labels
bug Identified bug which needs a fix
Milestone

Comments

@Pryanic
Copy link

Pryanic commented Apr 30, 2018

How to always use OR operator between groups and AND between rules?

@mistic100
Copy link
Owner

mistic100 commented Apr 30, 2018

A condition is not applied between items but inside a group, and a group can contain both groups and rules.
See #439

So in order to get the behavior you want, we should be able to restrict which groups can contain only groups or only rules, configuration hell !

The only thing you can do is initializing the builder and use the flags described here http://querybuilder.js.org/#method-setRules

$('#builder').queryBuilder({
  filters: ....,
  allow_empty: true,
  default_group_flags: {condition_readonly: true,  no_add_group: true},
});

$('#builder').queryBuilder('setRules', {
  condition: 'OR',
  flags: {no_add_rule: true, no_add_group: false}
});

This will restrict the builder to only two levels :

  • the first one (root) is OR and can only contain groups
  • any other group is AND and only contain rules

@Pryanic
Copy link
Author

Pryanic commented May 3, 2018

You described my dream thank you. I try it and get feedback

@Pryanic
Copy link
Author

Pryanic commented May 3, 2018

I tried to do and got
query-builder.standalone.min.js:7 Uncaught Error: Incorrect data object passed
at Object.h.error (query-builder.standalone.min.js:7)
at g.setRules (query-builder.standalone.min.js:6)
at r.fn.init.$.fn.queryBuilder (query-builder.standalone.min.js:7)

@mistic100
Copy link
Owner

add rules: [] to the object passed to "setRules"

When posting an error, please use the unminified version of the code, with the minified code it's impossible to find where the error is thrown.

@Pryanic
Copy link
Author

Pryanic commented May 3, 2018

Ty it's helped me.
But how I can remove button add group in subgroups
image
?

@mistic100
Copy link
Owner

This is a bug, the default_group_flags should be applied.

@mistic100 mistic100 added the bug Identified bug which needs a fix label May 3, 2018
@mistic100 mistic100 added this to the 2.5.2 milestone May 3, 2018
@saurabhsingh121
Copy link

I was searching for the way to remove the 'add group' button from sub groups. I landed up here. Please tell me how to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified bug which needs a fix
Projects
None yet
Development

No branches or pull requests

3 participants