Add an OK button to the searchBuilder modal

Add an OK button to the searchBuilder modal

FireNet999FireNet999 Posts: 11Questions: 3Answers: 0

I am using seachBuilder to good effect and getting all the functionality needed
However, after I complete the search, I then have to click off the modal window for it to close to view the results
Is there a way I could add an OK button similar to the cancel button to close the modal?

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 64,301Questions: 1Answers: 10,618 Site admin

    There is a liveSearch option for that. See this example and the docs here.

    Allan

  • FireNet999FireNet999 Posts: 11Questions: 3Answers: 0

    Many thanks Allan
    Most appreciated
    Regards
    Colin

  • FireNet999FireNet999 Posts: 11Questions: 3Answers: 0

    HI Alan
    I have inserted the liveSearch as false in the top layout which works fine.
    This method uses the page to take and show the parameters. However, I have the searchBuilder in a row of buttons, and when entered as 'searchBuilder', it opens in a modal window, as shown below.

    {
                        text: 'Create Member',
                        action: function () {
                            // Create new record
                            editor.create({
                            title: 'Create Member',
                            buttons: [
                { label: 'Cancel', fn: function () { this.close(); } }, 'Add'
                        ]
                            });
                        }
                    },
            'searchBuilder',        
            {
                        extend: 'savedStates',
                    text: 'Saved Filters',
                    buttons: [
                            'createState',
                            'removeAllStates',
                            {extend: 'spacer', style: 'bar'}
                        ]
                    },
    

    When I replace the above 'seachBuilder' with:

    searchBuilder: {
                    liveSearch: false
                },
    

    An error is given in the console as Unexpected token ':'

  • allanallan Posts: 64,301Questions: 1Answers: 10,618 Site admin
    Answer ✓

    Your buttons array should include:

    {
      extend: 'searchBuilder',
      config: {
        liveSearch: false
      }
    }
    

    where you want the button to appear (i.e. instead of 'searchBuilder'.

    If that doesn't work, please link to a test case so I can take a look.

    Allan

  • kthorngrenkthorngren Posts: 21,913Questions: 26Answers: 5,063
    Answer ✓

    See this example that shows how to configure SearchBuilder when using buttons.

    Kevin

  • FireNet999FireNet999 Posts: 11Questions: 3Answers: 0

    Many thanks both. That works a treat.

          {
             extend: 'searchBuilder',
              config: {
       depthLimit: 2,
        liveSearch: false
                        }
          }
    

    With regard to the liveSearch though when I press Search the modal window stays visible so I have to click off it to hide the modal window

  • allanallan Posts: 64,301Questions: 1Answers: 10,618 Site admin
    Answer ✓

    There isn't an option to have the modal hide on pressing the button at the moment. I can look into that in future.

    Allan

  • FireNet999FireNet999 Posts: 11Questions: 3Answers: 0

    Many thanks, Allan
    Colin

Sign In or Register to comment.