使用javascript从ASP.NET中的jqgrid以pdf格式下载数据 [英] Download data as a pdf format from a jqgrid in ASP.NET using javascript

查看:52
本文介绍了使用javascript从ASP.NET中的jqgrid以pdf格式下载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的jqgrid设计页面代码



Here is my jqgrid Design Page code

<div id='jqxWidget1'>

                                                              <div id="jqxgrid1">
                                                              </div>
                                                          </div>





这是我的HTML按钮





This im my html Button

<button type="button" id="pdfExport"   class="btn btn-warning">Export To PDF</button>







我已经在js中编写了javascript代码并在此页面中调用...



< script src =userScript / ComplianceReport.js>< / script>



我尝试过:



这是我的javascript代码...





$(#pdfExport)。click(function(){







var pdf = new jsPDF('p','pt','letter');

source = $( '#tab_customers')[0]; //表格ID

specialElementHandlers = {

'#htmlexportPDF':函数(元素,渲染器){

返回true

}

};

marginins = {//桌边距和宽度

顶部:80,

底部:60,

剩余:40,

宽度:100,

身高:200

};

pdf.fromHTML(

来源,

marginins.left,

marginins.top,{

'width':marginins.width,

'elementHandlers':specialElementHandlers

},



marginins);



var gridContent = $(#jqxgrid1)。jqxGrid('exportdata','html');

var filtercontent1 ='




And I had write the javascript code inside a js and call in this page...

<script src="userScript/ComplianceReport.js"></script>

What I have tried:

Here is my javascript code...


$("#pdfExport").click(function () {



var pdf = new jsPDF('p', 'pt', 'letter');
source = $('#tab_customers')[0]; //table Id
specialElementHandlers = {
'#htmlexportPDF': function (element, renderer) {
return true
}
};
margins = { //table margins and width
top: 80,
bottom: 60,
left: 40,
width: 100,
height: 200
};
pdf.fromHTML(
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},

margins);

var gridContent = $("#jqxgrid1").jqxGrid('exportdata', 'html');
var filtercontent1 = '

访问类型: - 营地名称: - 时间持续时间: -
Visit Type:-Camp Name:-Time Duration:-

'

pageContent =

'<!DOCTYPE html> \ n'+

'< html> \ n'+

'< head> \ n'+

'< meta charset =utf-8/> \ n'+

'< title> ;营地时间表报告< / title> \ n'+

'< / head> \ n'+

'< body> \ n'+ filtercontent1 +'\ n'+ gridContent +'\ n< / body> \ n< / html>';

// filtercontent + = gridContent;

console.log(pageContent);

pdf.fromHTML(pageContent,15,15,{

'width':270,

'elementHandlers ':specialElementHandlers

});

pdf.save('CampScheduleReport.pdf');





});





谢谢&问候

Bigyan Sahoo

'
pageContent =
'<!DOCTYPE html>\n' +
'<html>\n' +
'<head>\n' +
'<meta charset="utf-8" />\n' +
'<title>camp schedule report</title>\n' +
'</head>\n' +
'<body>\n' + filtercontent1 + '\n' + gridContent + '\n</body>\n</html>';
//filtercontent += gridContent;
console.log(pageContent);
pdf.fromHTML(pageContent, 15, 15, {
'width': 270,
'elementHandlers': specialElementHandlers
});
pdf.save('CampScheduleReport.pdf');


});


Thanks & Regards
Bigyan Sahoo

推荐答案

(#pdfExport)。click(function(){

< br $>




var pdf = new jsPDF('p','pt','letter');

source =
("#pdfExport").click(function () {



var pdf = new jsPDF('p', 'pt', 'letter');
source =


('#tab_customers')[0]; //表格ID

specialElementHandlers = {

'#htmlexportPDF' :function(element,renderer){

返回true

}

};

marginins = {//桌边距和宽度

顶部:80,

底部:60,

左:40,

宽度: 100,

身高:200

};

pdf.fromHTML(

来源,

marginins.left,

marginins.top,{

'width':marginins.width,

'elementHandl ers':specialElementHandlers

},



保证金);



var gridContent =
('#tab_customers')[0]; //table Id
specialElementHandlers = {
'#htmlexportPDF': function (element, renderer) {
return true
}
};
margins = { //table margins and width
top: 80,
bottom: 60,
left: 40,
width: 100,
height: 200
};
pdf.fromHTML(
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},

margins);

var gridContent =


(#jqxgrid1)。jqxGrid('exportdata','html');

var filtercontent1 ='
("#jqxgrid1").jqxGrid('exportdata', 'html');
var filtercontent1 = '
访问类型: - 营地名称: - 时间持续时间: -
Visit Type:-Camp Name:-Time Duration:-

'

pageContent =

'<!DOCTYPE html> \ n'+

'< html> \ n'+

'< head> \ n'+

'< meta charset =utf-8/> \ n'+

'< title>营地时间表报告< / title> \ n'+

'< / head> \ n'+

'< body> \ n'+ filterconten t1 +'\ n'+ gridContent +'\ n< / body> \ n< / html>';

// filtercontent + = gridContent;

console.log(pageContent);

pdf.fromHTML(pageContent,15,15,{

'width':270,

'elementHandlers ':specialElementHandlers

});

pdf.save('CampScheduleReport.pdf');





});





谢谢&问候

Bigyan Sahoo

'
pageContent =
'<!DOCTYPE html>\n' +
'<html>\n' +
'<head>\n' +
'<meta charset="utf-8" />\n' +
'<title>camp schedule report</title>\n' +
'</head>\n' +
'<body>\n' + filtercontent1 + '\n' + gridContent + '\n</body>\n</html>';
//filtercontent += gridContent;
console.log(pageContent);
pdf.fromHTML(pageContent, 15, 15, {
'width': 270,
'elementHandlers': specialElementHandlers
});
pdf.save('CampScheduleReport.pdf');


});


Thanks & Regards
Bigyan Sahoo


这篇关于使用javascript从ASP.NET中的jqgrid以pdf格式下载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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