Searchbuilder Predefined Search Not Working

Searchbuilder Predefined Search Not Working

JargenJargen Posts: 8Questions: 2Answers: 0
edited April 2023 in Free community support

I'm trying to use a predefined search on a datatable using serverside processing. If i do the search via the builder it works fine, but through the code nothing happens and the request isn't sent. This is the code i am using

var dataTable = $('#sample_data').DataTable({
                "processing": true,
                "serverSide": true,
                "pageLength": 100,
                "order":[],
                "ajax":{
                    url:"fetch.php",
                    type:"POST",
                },
                dom: 'Qfrtip',
                searchBuilder:{
                    preDefined: {
                        criteria:[
                            {
                                condition: '=',
                                data: 'Society',
                                origData: 'society',
                                type: 'string',
                                value: ['SOCIETYNAME']
                            }
                        ],
                        logic: 'AND',
                    }
                },

Answers

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    What version of SearchBuilder do you have? This is from the SB Server Side Processing docs.

    Since SearchBuilder 1.2.0 a server-side integration has been supported which allows complex queries to be constructed on the client-side before being processed on the server-side.

    Kevin

  • JargenJargen Posts: 8Questions: 2Answers: 0

    I am running 1.4.1, so well within that version

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    I copied your code here:
    https://live.datatables.net/qoliyehi/15/edit

    Its working. I changed data, origData and value to match the test case configuration.

    Do you get errors in the browser's console?

    Can you post a link to your page or provide a test case replicating the issue so we can help debug?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • JargenJargen Posts: 8Questions: 2Answers: 0

    Sadly there is no easy way for me to give a test case currently. However i have just found out that if i click on one of the columns to sort them then the search is applied. Is there a way to force a refresh of the table?

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    edited April 2023

    Is there a way to force a refresh of the table?

    You can try calling draw() in initComplete. Use this.api().draw().

    Kevin

  • JargenJargen Posts: 8Questions: 2Answers: 0

    Sadly that isn't working either. Theres no errors at all too. Is there a way I can give you access to see the page in a private way rather then on a public thread?

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    You can PM Allan using the Ask a Private Question button.

    My example uses SB 1.4.2. I don't see anything in the release notes but maybe try upgrading to see if an issue causing the request to not be sent was fixed.

    Kevin

  • JargenJargen Posts: 8Questions: 2Answers: 0

    Sorry can't see a ask a private question button, only ask a question?

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    Sorry can't see a ask a private question button, only ask a question?

    @allan will need to look at that. This is the second time I've seen this comment. Try going to your inbox. Look for the button there or use the New Message button and send a message to allan with access details.

    Kevin

Sign In or Register to comment.