SearchBuilder Predefined Search does not work with Button Implementation

SearchBuilder Predefined Search does not work with Button Implementation

jaygraysonjaygrayson Posts: 17Questions: 3Answers: 0

Link to test case:
This is without button implementation, showing working:
https://codepen.io/p2g-jaygrayson/pen/yLprJdr

This is with button implementation, showing not working:
https://codepen.io/p2g-jaygrayson/pen/PoEgGoR

Description of problem:
When using the Button implementation, SearchBuilder does not honor the Predefined Search.

Replies

  • jaygraysonjaygrayson Posts: 17Questions: 3Answers: 0

    Well, my colleague found the answer to this one. I updated the second CodePen, that I labeled as showing not working.

    https://codepen.io/p2g-jaygrayson/pen/PoEgGoR

    The issue was that the predefined criteria needs to be declared inside the button initialization, not the searchbuilder config.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    That's it, yep, glad all sorted,

    Colin

  • the_macethe_mace Posts: 10Questions: 3Answers: 0

    I have a problem that seemed like this one but the solution doesnt work for me. Im using server side tables and no filter is sent to the backend from the predefined setup.

    I'm in a button (similar to the OP), so it looks like this:

                            extend: 'searchBuilder',
                            config: {
                                preDefined: {
                                    criteria: [
                                        {
                                            data: 'First',
                                            origData: 'first',
                                            condition: '=',
                                            type: 'string',
                                            value: ['firstname']
                                        }
                                    ]
                                },
                                columns: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
                            }
    

    The preDefined option doesn't seem to do anything. What I see at the server is no searchBuilder at all:

    start=0&
    length=5&
    search[value]=&
    search[regex]=false
    

    When done through the interactive searchBuilder I see something more expected:

    start=0&
    length=5&
    search[value]=&
    search[regex]=false&
    searchBuilder[criteria][0][condition]==&
    searchBuilder[criteria][0][data]=First&
    searchBuilder[criteria][0][origData]=first&
    searchBuilder[criteria][0][type]=string&
    searchBuilder[criteria][0][value][]=firstname&
    searchBuilder[criteria][0][value1]=firstname&
    searchBuilder[logic]=AND
    

    Any ideas would be helpful.

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765

    Defining the predefined criteria in the buttons config works here:
    https://live.datatables.net/yuyohuvi/1/edit

    Notice there are two ajax requests. The first is the standard SSP request and the second is the request with the predefined criteria. If this doesn't help then please post a link to your page or a test case replicating the issue so we can help debug.

    Kevin

Sign In or Register to comment.