在safari浏览器中使用jqxgrid导出CSV并且iOS无效 [英] Export CSV using jqxgrid in safari browser and iOS is not working

查看:209
本文介绍了在safari浏览器中使用jqxgrid导出CSV并且iOS无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网络应用程序中,我可以选择将jqxgrid数据导出为.CSV格式。



它在Chrome& Firefox浏览器。但是,如果,我在'Safari'浏览器中尝试了导出选项,它将打开它在另一个选项卡中,而不是将其作为单独的文件下载。



是吗有可能将其作为单独的文件下载吗?



示例代码:

-------------------- -




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";
}





我的尝试:



另外,我在下面试过这些



浏览器设置 - >

隐私 - >

阻止cookies:

从不



限制网站访问位置服务:

在没有提示的情况下拒绝



What I have tried:

Also, I have tried these below

Browser Settings -->
Privacy -->
Block cookies:
Never

Limit website access to location services:
Deny without prompting

推荐答案

#gridExport )。click( function (){
exportData = [];
var exportType = GetExportFormat(); // csv(或)xls
exportInfo =
("#gridExport").click(function () { exportData = []; var exportType = GetExportFormat(); //csv (or) xls exportInfo =


#jqxgrid)。jqxGrid(< span class =code-string>' exportdata',exportType);
exportInfo = replaceAll(exportInfo,' & lt; br /& gt;'' ');
尝试 {
var prm = {};
prm.exportInfo = exportInfo;
saveMyFile(
("#jqxgrid").jqxGrid('exportdata', exportType); exportInfo = replaceAll(exportInfo, '&lt;br/&gt;', ' '); try { var prm = {}; prm.exportInfo = exportInfo; saveMyFile("


('SubmitForm'), 测试 + + exportType,exportInfo, text / + exportType + ; charset = utf-8);
}
catch (e){
console .log( ' 导出错误:' + e);
}
});


function saveMyFile(ref,fname,text,mime){
尝试 {
var blob = new Blob([text], {type:mime});
saveAs(blob,fname);
return false ;
} catch (e){
console .log( saveMyFile:' + e.message);
}
}



function GetExportFormat(){
< span class =code-keyword> 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;
}
('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"; }





我的尝试:



另外,我在下面试过这些



浏览器设置 - >

隐私 - >

阻止cookies:

从不



限制网站访问位置服务:

在没有提示的情况下拒绝



What I have tried:

Also, I have tried these below

Browser Settings -->
Privacy -->
Block cookies:
Never

Limit website access to location services:
Deny without prompting


这篇关于在safari浏览器中使用jqxgrid导出CSV并且iOS无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆