Filter only after pressing ENTER

Filter only after pressing ENTER

trongarttrongart Posts: 222Questions: 51Answers: 0

The default search filter shows results real-time "as you type". Is it possible to stop this function and to only filter and show results after the user presses ENTER? Would this also apply to filters from the SearchBuilder?

This question has an accepted answers - jump to answer

Answers

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    The following code activates search only after the input has been typed in and ENTER was pressed, which is what I was looking for:

                      initComplete: function() {
                          $('.dataTables_filter input').unbind();
                          $('.dataTables_filter input').bind('keyup', function(e){
                              var code = e.keyCode || e.which;
                              if (code == 13) {
                                  table.search(this.value).draw();
                              }
                          });
                      },
    

    However, this does not work with the SearchBuilder. It still searches at every keystroke. How could I apply the same to the SearchBuilder?

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @trongart ,

    This is possible for SearchBuilder, but you would have to make a bunch of custom conditions to do it. We think that this is a good idea though so I am going to add an initialisation option for it. (For my reference, the issue to track this will be DD-1958) I'll report back here when this is done, shouldn't be too long!

    Thanks,
    Sandy

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

    Hi @trongart ,

    I've added a new Initialisation option searchBuilder.enterSearch, if you set it to true in your initialisation then a search will only be triggered in an input element when you press enter. Take a look at this example to see it in action.

    This 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.

    Thanks,
    Sandy

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    Amazing- This works, thank you so much for this!

  • timothy_chitimothy_chi Posts: 2Questions: 0Answers: 0

    The night build version also fixed that the Chinese IME does not work for the value input field.

    Awsome Work!!!!

    Thank You ^_^

  • timothy_chitimothy_chi Posts: 2Questions: 0Answers: 0

    Dear @sandy

    Thanks for the awsome project.

    There is a pull request is about add a div element into logic button.
    It's giving a chance to ro rotate text.
    Please take a look at this example to see the effect
    and then review the pull request in the github.

    Thanks again!

    Timothy

    logicButton

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @timothy_chi ,

    I've replied and pulled in your PR on GitHub.

    Thanks for contributing!

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    @sandy The searchBuilder.enterSearch no longer works with this nighty build, also not in the example. Has there been an update to the nighty build?

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @trongart ,

    I'm just about to finish up for today but I'll take a look first thing tomorrow morning.

    Thanks,
    Sandy

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    Sure, thank you very much for checking @sandy !

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @trongart ,

    That should be fixed again now, you may need to break the cache on the url in your script tag (just add "?adfbg" to the end).

    Thanks again for pointing this out,
    Sandy

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    Works again! Appreciate your help @Sandy

Sign In or Register to comment.