4

I am using Jquery Query Builder. It has AddRule and AddGroup Functions i want to add one more feature called as end of query named as "Groupby". Then i should be able to choose mutie feild where same feild name should be able to access with Json.

Ex http://querybuilder.js.org/demo.html I want to add one more button, on clicking that one moew row will be populated at bottom to choose fields for grouping. Note : Not a group of query, rather place to choose feild for SQL Grouping

user3815413
  • 385
  • 2
  • 20

1 Answers1

0

You can create a custom operator for GroupBy on the queryBuilder configuration with the other predefined operator too, like

$('#builer').queryBuilder({
    filters: filters,
    allow_groups: false,
    operators: [{
        type: 'groupby',
        label: 'Group By',
        nb_inputs: 0,
        multiple: false,
        apply_to: ['string', 'number']
    },
    {type: 'equal', nb_inputs: 1, multiple: false, apply_to: ['string', 'number']},
    {type: 'not_equal', nb_inputs: 1, multiple: false, apply_to: ['string', 'number']},
    {type: 'less', nb_inputs: 1, multiple: false, apply_to: ['number']},
    {type: 'less_or_equal', nb_inputs: 1, multiple: false, apply_to: ['number']},
    {type: 'greater', nb_inputs: 1, multiple: false, apply_to: ['number']},
    {type: 'greater_or_equal', nb_inputs: 1, multiple: false, apply_to: ['number']},
    {type: 'between', nb_inputs: 2, multiple: false, apply_to: ['number']}
]
});

Tada!!!

It will show the custom operator like below. Happy coding!

enter image description here

Jakpren
  • 71
  • 6