Hey there, Awesome Customers!

Just a heads up: We'll be taking a breather to celebrate International Workers' Day (May 1st and 2nd - Wednesday and Thursday) and Orthodox Easter from Good Friday (May 3rd) through Easter Monday (May 6th). So, from May 1st to May 6th, our team will be off enjoying some well-deserved downtime.

During this time, our customer support will be running on a smaller crew, but don't worry! We'll still be around to help with any urgent matters, though it might take us a bit longer than usual to get back to you.

We'll be back in action at full throttle on May 7th (Tuesday), ready to tackle your questions and requests with gusto!

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find loads of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel). These gems might just have the answers you're looking for while we're kicking back.

Thanks a bunch for your understanding and support!

Catch you on the flip side!

Warm regards,

TMS

Okay
  Public Ticket #2304297
Trigger report download with javascipt?
Closed

Comments

  • Simon started the conversation

    I'm looking for a way to trigger the report to download on page ready. 

    I have tried the following, with no success. Is there a javascript function I can call instead of trying to trigger the download button being clicked?

    The console.log statements show up in the console, and I'm not generating any errors - but my report isn't being downloaded, unless I click the button. 

    <script>
    jQuery(document).ready(function($) {
        $(".reportbuilder_button download btn waves-effect").click();
        console.log("Ran the javascript click event...");
        $(".reportbuilder_button download btn waves-effect").trigger('click');console.log("Ran the javascript trigger click event...");
    });
    </script>


  • Simon replied

    As a slight update on this - still not resolved. 

    Using the following initiates the button click, but generates a further error with the filtering being passed to the stringify function - perhaps the datatable is still being loaded when the document.load function is still waiting on results. Not sure how to overcome this. 


    <script>
    jQuery(document).ready(function($) {

        $(".reportbuilder_button").attr('id',"downbutt");
        $(".reportbuilder_button").click();

        $(".reportbuilder_button").trigger(click); //alternatively. 

    });

       console.log("Ran the javascript click event...");

    </script>


  •  2,499
    Aleksandar replied

    Hello Simon

    Sorry for the late response.

    I don't know if this could be achieved, but it has been forwarded to one of our developers, and I'll get back to you as soon as I get a response from him.

    If we can help you out with a hint, or if this is possible with a small correction of your custom code, we will gladly assist you. However, if it turns out to be a more complex task, we won't be able to help. Please note that something like this is considered customization of the plugin, and doesn't fall under included support.

    I'll get back to you as soon as possible.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2,499
    Aleksandar replied

    Hi again Simon.

    The first script doesn't work simply because the selector is wrong (download, btn..). They are all classes, and you need to write them together, because they are all parts of one element.

    Please add this code on your page, and test:

    [reportbuilder id=1 text="Download report" class="btn"]
    <script>
    jQuery(document).ready(function(){ jQuery(".reportbuilder_button").click(); //trigger event after listening to it.
    });
    </script>

    If that too doesn't work, perhaps there's a plugin active on your website that's causing a conflict; or if you have more buttons on the page, you need to locate the one you need, because with this class there are several buttons, and JS doesn't know which one should be clicked.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Simon replied

    So this doesn't quite work, and the reason why seems to be that when document.ready is triggered the data table has not finished receiving all the data and filtering. 

    This function might work if serverside filtering were enabled, but alas I'm filtering from a gravity forms input and thus server side filtering isn't what I'm after. 

    This is certainly a function that has benefits in a number of other places. For example I'm using the function to trigger download of a report from a html table of links. I have 80 rows, and 5 columns - each can supply a different report. I don't mind the data being loaded into the users browser, but I don't want them seeing the table - so it's easier to hide the table, use a url filter, and trigger the download function some other way.  

  •  2,499
    Aleksandar replied

    Hi again Simon.

    You can try using load:

    <script>
    jQuery(window).on('load',function(){ jQuery(".reportbuilder_button").click();
    });
    </script>

    Can you please try that?

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables