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.
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.
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.
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.
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.
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>
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>
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
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:
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
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.
Hi again Simon.
You can try using load:
Can you please try that?
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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