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

Querybuilder not clearing data objects on reset. #691

Closed
thebirdman7 opened this issue May 2, 2018 · 5 comments
Closed

Querybuilder not clearing data objects on reset. #691

thebirdman7 opened this issue May 2, 2018 · 5 comments
Labels
bug Identified bug which needs a fix
Milestone

Comments

@thebirdman7
Copy link

I am writing an application where I need to save the queries generated out of querybuilder. I am using the default format (not Mongo or SQL). I am passing my identity elements in the recommended data object on the group and rule levels. When the user clicks create to create a new rule, I call a reset at that time. However when I call the getrules for the new rules, it shows a data element from the last rule on the parent node of the rules. Unfortunately, what this ends up doing is attaching all my new rules to my old rules. I can probably find a workaround for this, but wanted to let you know. If you have any suggestions that would be great.

Thanks.

@mistic100
Copy link
Owner

Can you show some code ? or better a demo ? Because clearly I don't understand.

@thebirdman7
Copy link
Author

thebirdman7 commented May 2, 2018

This is the json retrieved from 'getRules' after a 'reset' is performed and some new fields are selected.
Note at the bottom there is a data object containing an identifier. This is the identifier from the querybuilder query that existed prior to the reset when a 'setRules' was called as I entered the page.

{
  "condition": "AND",
  "rules": [
    {
      "id": 1,
      "field": "age",
      "type": "integer",
      "input": "number",
      "operator": "greater",
      "value": 17
    },
    {
      "id": 1,
      "field": "age",
      "type": "integer",
      "input": "number",
      "operator": "less",
      "value": 60
    }
  ],
  "data": {
    "identifier": 83
  },
  "valid": true
}

@thebirdman7 thebirdman7 changed the title Querybuilder not clearing data elements on reset. Querybuilder not clearing data objects on reset. May 2, 2018
@mistic100
Copy link
Owner

Ok it's the data associated to the main group.

Waiting for a fix you can replace your call to "reset" to "setRules" with an empty rules set.

{
  "condition": "AND",
  "rules": [
    {
      "empty": true
    }
  ]
}

and please read this for your future messages : https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown
(I edited your last message)

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

Thanks for the prompt reply. I will give your suggestion a try.

@thebirdman7
Copy link
Author

That does work. Thanks!

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

2 participants