Last active
April 5, 2019 00:09
-
-
Save Kobedinho/9cd4059cd358be2fa8e31e1efda8089a to your computer and use it in GitHub Desktop.
Custom button to download a PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file: custom/Extension/modules/<module>/Ext/Language/en_us.customPdfButton.lang.php | |
<?php | |
$mod_strings['LBL_PDF_BUTTON'] = 'PDF'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file: custom/modules/<module>/clients/base/views/supanel-list/supanel-list.js | |
({ | |
extendsFrom: 'SubpanelListView', | |
// adding the listener to custom button event | |
contextEvents: { | |
"list:editall:fire": "toggleEdit", | |
"list:editrow:fire": "editClicked", | |
"list:unlinkrow:fire": "warnUnlink", | |
"list:pdfbtn:fire": "downloadPdf" | |
}, | |
/** | |
* Handle click on custom button | |
*/ | |
downloadPdf: function(model) { | |
// TO DO | |
console.log('Helo!!!'); | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suggest to use the function: app.api.fileDownload.
Function definition:
/**
* Given a url, attempts to download a file.
*
* @param {string} url url to call
* @param {Object} [callbacks] Callback object
* @param {Object} [options] Options object
* - iframe: jquery element upon which to attach the iframe for download
* if not specified we must fall back to window.location.href
* @memberof Api
* @instance
*/
fileDownload: function(url, callbacks, options)
How to use it:
app.api.fileDownload(url, {
error: function(data) {
app.error.handleHttpError(data, {});
}
}, {
iframe: this.$el
});