• Resolved kebhin

    (@kebhin)


    Hi

    I’m using the advanced options in publications to initialise the search builder with a predefined query, like this:

    {
    “dom”: “Q”,
    “searchBuilder”: {
    “preDefined”: {
    “criteria”:[
    {
    “condition”: “between”,
    “data”: “Trip Date”,
    “value”: [“2023-10-01″,”2024-03-31”]
    }
    ],
    “logic”: “AND”
    }
    }}

    This works as expected, however I don’t want to hard code the dates here. Can you tell me what is the best way to initialise these values, given URL parameters or the right place to hook in some javascript

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Kim L

    (@kimmyx)

    Hi @kebhin,

    We have a reference on how to use JavaScript functions in your Advanced Settings here: Advanced Options – Using JavaScript Functions

    Let us know if that helps! ??

    Thread Starter kebhin

    (@kebhin)

    Hi Kim

    I looked at this and the Datatables references and came up with this starting point to change the values from javascript:

    Add this line to advanced options (I also tried “initComplete”):

    “drawCallback”: “function(settings,json) {settable(settings,json)}”,

    This is the function ‘settable’:

    function settable(settings,json) {
        var table = jQuery('#'+settings.sTableId).DataTable();
        var s = table.searchBuilder;
        if (s != null) {
            var c = s.getDetails();
            c[0].value[0]='2024-01-01';
            s.rebuild(c);
        }
    }

    The intention is to change the starting date of the search to 2024-01-01 however it does not work, an exception is thrown and the searchbuilder is not displayed: Here is the exception from java console:

    dataTables.searchBuilder.min.js:127 Uncaught TypeError: Cannot read properties of undefined (reading 'getDetails')
        at c.getDetails (dataTables.searchBuilder.min.js:127:449)
        at B.<anonymous> (dataTables.searchBuilder.min.js:146:157)
        at Object.getDetails (jquery.dataTables.min.js?ver=5.2.5:122:332)
        at settable (full-detail/:253:19)
        at Object.eval [as userDrawCallback] (eval at convert_string_to_function (wpda_datatables.js?ver=5.2.5:732:13), <anonymous>:3:33)
        at e.<computed>.drawCallback (wpda_datatables.js?ver=5.2.5:678:36)
        at jquery.dataTables.min.js?ver=5.2.5:91:103
        at Function.map (jquery.min.js?ver=3.7.1:2:3971)
        at F (jquery.dataTables.min.js?ver=5.2.5:91:50)
        at ja (jquery.dataTables.min.js?ver=5.2.5:44:108)

    I understand that this a fairly complex case and I’m asking a lot of support, but is there anything similar someone has done or perhaps a completely different approach for initialising the searchbuilder?

    Plugin Contributor Kim L

    (@kimmyx)

    Hi @kebhin,

    Thanks for the response.

    Unfortunately, we don’t have existing samples similar to your use-case, but the following links might give you more ideas:

    We hope that helps. ??

    Thread Starter kebhin

    (@kebhin)

    I was able to solve this issue myself with Javascript, this was plugin version 5.2.5

    However when I upgrade to 5.5.3, it no longer works and in fact the table is not displayed at all. I found that the “dom” option may not be supported so I removed that from advanced options. Then the table and search builder panes are displayed but the search builder is not initialised as specified in the options.

    I’ve removed the Javascript from the page – so that’s not the issue. I don’t see any relevant exceptions in the Java console either.

    It looks like the advanced options are no longer supported in 5.5.3, or if they are there must be a change to syntax or semantics. The documentation has not been updated since around 2020

    Can you help on this? Do you want me to go to Premium Support for these advanced issues?

    Plugin Contributor Kim L

    (@kimmyx)

    Hi @kebhin,

    We’re sorry to hear you encountered issues when you updated the plugin.

    Advanced Options still works up to the latest version which is 5.5.6. Could you try to update to the latest version to see if that resolves the issue?

    See our test here: https://share.zight.com/jkup0xxn

    Have you also tested for any conflict with your other plugins/themes?

    If the issue persists after updating to the latest, kindly send us a ticket so we can take a closer look. ??

    The plugin is currently transitioning to a faster and more stable way of creating tables. This means the old tools haven’t been maintained for a while (but they should still work as usual), and will soon be replaced by our new tool, the App Builder. You can explore more about it here: What’s the App Builder? | WP Data Access

    We’ll wait for your email!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.