In my web application i have an option to export "jqxgrid" data to ".CSV" format.
It is working as expected in Chrome & Firefox browsers. But, if, I tried the export option in 'Safari' browser it is opening it is in another tab, instead of download it as a separate file.
Is it possible to download it as a separate file?
Sample Code:
$("#gridExport").click(function () {
exportData = [];
var exportType = GetExportFormat(); //csv (or) xls
exportInfo = $("#jqxgrid").jqxGrid('exportdata', exportType);
exportInfo = replaceAll(exportInfo, '<br/>', ' ');
try {
var prm = {};
prm.exportInfo = exportInfo;
saveMyFile("$('SubmitForm')", "Test" + "." + exportType, exportInfo, "text/" + exportType + ";charset=utf-8");
}
catch (e) {
console.log('Export Error: ' + e);
}
});
function saveMyFile(ref, fname, text, mime) {
try {
var blob = new Blob([text], { type: mime });
saveAs(blob, fname);
return false;
} catch (e) {
console.log('saveMyFile: ' + e.message);
}
}
function GetExportFormat() {
var strPlatform = navigator.platform;
if (strPlatform.toLowerCase().indexOf('ipad') > -1 ||
strPlatform.toLowerCase().indexOf('iphone') > -1 ||
strPlatform.toLowerCase().indexOf('mac') > -1)
return "csv";
else
return "xls";
}