mistic100 / mistic100/jQuery-QueryBuilder
Complex Operators with custom inputs (eg modulo)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 544
- PR merge metrics
- No merged PRs in 30d
Description
I am looking for a way to implement a modulo operator, but I am not sure what might be the way to do so.
When selecting the modulo op the resulting rule should display something like this (please ignore the first and last select, the image is taken from the current implementation):

The idea is to model operations like:
field % value = 5
field % value > 10
....
I've been able to add the modulo operator but all the fields are now shown as inputs for numbers:
(function() {
var QueryBuilder = jQuery.fn.queryBuilder,
operators = QueryBuilder.defaults('operators'),
operatorsAsArray = Object.keys(operators).map(function (key) {return operators[key]});
operatorsAsArray.push({
type: 'modulo',
nb_inputs: 3,
apply_to: ['number']
});
QueryBuilder.defaults({operators: operatorsAsArray});
})();

Is there a way to specify custom inputs or a template for an operator?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the operator registration shown through QueryBuilder.defaults and trace how nb_inputs and apply_to determine the rendered controls. Inspect the operator UI handling to determine whether custom inputs or templates are supported, then verify that modulo expressions render and preserve the intended field, value, and comparison controls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 39/100