Search Builder - Auto Select Condition

Search Builder - Auto Select Condition

fiji885fiji885 Posts: 7Questions: 3Answers: 0

Link to test case: http://live.datatables.net/haqewiku/1/edit

Description of problem: When I go to select a 'Data' field, is there a way to have it automatically choose the condition? I want the 'contains' condition to be automatically chosen (user should not have to click conditions and 'contains' condition should be applied automatically).

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590
    edited March 2022

    You could do something like this: http://live.datatables.net/gacefuwa/1/edit

      $('.dataTables_wrapper').on('change','.dtsb-data',  function(e, el) {
        var cond = $(e.currentTarget).next();
        var opts = $("option[disabled!='disabled']", cond);
        if (opts.length === 1) {
          $(cond).val(opts.attr('value'));
          $(cond).trigger('change');
        }
      });
    

    It's checking to see how many options are enabled, and if only one, then select it.

    I like the idea of a default condition, I'll see if the other think it's an option. I've raised it internally (DD-2512 for my reference) and we'll report back here when there's an update.

    Cheers,

    Colin

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi @fiji885 ,

    Just to let you know that we have implemented this and it will be available in the next SearchBuilder release which we hope will be in the next few weeks. Until then you can access the fix from the nightly builds.

    Until then, you can see it in action at this example.

    Thanks,
    Sandy

Sign In or Register to comment.