jQuery-QueryBuilder icon indicating copy to clipboard operation
jQuery-QueryBuilder copied to clipboard

getRules on boolean type returns differently when there are more than one operator

Open maryhadalittlelamb opened this issue 5 years ago • 5 comments

Hi, I am using filter with boolean type. I realise that 'getRules' doesn't work as expected when there are more than one operator.

The reason why i need two operators (ie. "equal" and "not_equal") because I have integrated your filter with the ability to input a dynamic value from somewhere else. Thus it would be helpful if I can do eg.

param_1 = "true"
test: field_1 equal param_1
test: field_1 not_equal param_1

Fiddle below: Works - One operator, getRules return 1 or 0 https://jsfiddle.net/fh7q3Lz4/7/

Fail - Two operators, getRules return true or false https://jsfiddle.net/fh7q3Lz4/8/

I have tested with an older version that works (ie. 2.4.3) https://jsfiddle.net/fh7q3Lz4/9/

maryhadalittlelamb avatar Apr 18 '19 08:04 maryhadalittlelamb

There is not difference between your two examples , both have the same behavior :

  • if you hit "getRules" without touching the rule you get "0"
  • if you change the rule value your true or false (which is the correct behavior as typed boolean)

mistic100 avatar Apr 18 '19 08:04 mistic100

Sorry, please try clicking on the true/ false radio and getRules again. Because then it will trigger the correct onchange

maryhadalittlelamb avatar Apr 18 '19 08:04 maryhadalittlelamb

To replicate: Click true radio button Click "Get Rules" Click "Set Rules"

The radio button will not be selected now

maryhadalittlelamb avatar Apr 18 '19 08:04 maryhadalittlelamb

Yas that's exactly what I said.

Now why are you using type: 'boolean' if you want "0" and "1" as string ?

mistic100 avatar Apr 18 '19 08:04 mistic100

You're right. First 2 has the same behavior, my bad. Only the older version has the behavior I was expecting. Are you suggesting that I should get 0 or 1 as integer in order to work?

maryhadalittlelamb avatar Apr 18 '19 08:04 maryhadalittlelamb