Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
GridJs provides a flexible download mechanism that allows you to customize the file download behavior. You can set a custom download function to handle file downloads according to your requirements.
GridJs provides the setFileDownloadCallFunction method to set a custom download function. When users click the download button, this function will be called with specific parameters.
// Define your custom download function
function customDownloadHandler(toFileName, outputType, saveMode) {
console.log('File Name:', toFileName);
console.log('Output Type:', outputType);
console.log('Save Mode:', saveMode);
// Implement your custom download logic here
// For example: upload to cloud storage, save to custom location, etc.
}
// Set the custom download function
xs.setFileDownloadCallFunction(customDownloadHandler);
The custom download function receives three parameters:
"myfile.xlsx", "report.pdf"Original - Keep the original file formatXLSX - Export as Excel formatPDF - Export as PDF formatHTML - Export as HTML formatDevice - Download to local device (default)GoogleDrive - Save to Google DriveDropbox - Save to DropboxGridJs supports multiple download scenarios based on different user actions:
function customDownloadHandler(toFileName, outputType, saveMode) {
switch(outputType) {
case 'Original':
// Handle original format download
downloadAsOriginal(toFileName);
break;
case 'XLSX':
// Handle Excel format download
downloadAsExcel(toFileName);
break;
case 'PDF':
// Handle PDF format download
downloadAsPDF(toFileName);
break;
case 'HTML':
// Handle HTML format download
downloadAsHTML(toFileName);
break;
}
}
xs.setFileDownloadCallFunction(customDownloadHandler);
function customDownloadHandler(toFileName, outputType, saveMode) {
if (saveMode === 'GoogleDrive') {
// Implement Google Drive upload logic
uploadToGoogleDrive(toFileName, outputType);
} else if (saveMode === 'Dropbox') {
// Implement Dropbox upload logic
uploadToDropbox(toFileName, outputType);
} else {
// Default: download to device
downloadToDevice(toFileName, outputType);
}
}
xs.setFileDownloadCallFunction(customDownloadHandler);
Function Registration: Make sure to call setFileDownloadCallFunction before users interact with the download functionality.
Error Handling: Always implement proper error handling in your custom download function to provide feedback to users.
Async Operations: If your download logic involves asynchronous operations (like API calls), make sure to handle promises appropriately.
File Name Extension: When the output type is not “Original”, the file extension will be automatically adjusted to match the output type (e.g., .xlsx, .pdf, .html).
Default Behavior: If you don’t set a custom download function, GridJs will use its default download behavior.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.