-
Create a Procedure: Tab Builders -> Procedure -> Add
-
Code: BrowseDownloadToCSV
-
Give it a description. (E.g. Downloads data in a Browse Screen as a csv)
-
Paste the PHP code from the file BrowseDownloadToCSV.php to the PHP field.
-
Save
-
Add this JavaScript Code to your form’s Custom Code field:
function base64encode(str) {
let encode = encodeURIComponent(str).replace(/%([a-f0-9]{2})/gi, (m, $1) => String.fromCharCode(parseInt($1, 16)))
return btoa(encode)
}
function browseDownloadToCSV() {
nuSetProperty('browse_sql', base64encode(JSON.stringify(nuCurrentProperties().browse_sql)));
nuRunPHP('BrowseDownloadToCSV');
}
if(nuFormType() == 'browse'){
nuAddActionButton('browseDownloadToCSV', 'Download to CSV', 'browseDownloadToCSV();');
}
- Save
Now you see a new button "Download to CSV" in your Browse Screen!