使用javascript从jqgrid下载PDF数据 [英] Download PDF data from jqgrid using javascript
问题描述
这是我从jqgrid下载PDF的代码。我在我的页面中调用此js页面。 pdfExport是我的按钮ID。
$(文件).ready(function(){
$ (#pdfExport)。click(function(){
// alert(clicked);
// alert($(#jqxgrid1)。 jqxGrid);
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':ma rgins.width,
'elementHandlers':specialElementHandlers
},
边距);
var gridContent = $(#jqxgrid1)。jqxGrid('exportdata','html');
var filtercontent1 ='
Here is My code for download PDF from a jqgrid. I call this js page in My page. pdfExport is my button Id.
$(document).ready(function () {
$("#pdfExport").click(function () {
//alert("clicked");
//alert($("#jqxgrid1").jqxGrid);
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('CampScheduleReport1.pdf');
});
});
我尝试了什么:
我的另一页同样的代码工作,但在这里我找不到错误。所以PLZ修好它或为它发送一些新的逻辑..
问候
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('CampScheduleReport1.pdf');
});
});
What I have tried:
Same code work for my another page, but here I can't find the error. so plz fixed it or send some new logic for it..
Regards
Bigyan Sahoo
推荐答案
(document).ready(function(){
(document).ready(function () {
(#pdfExport)。click(function) (){
// alert(clicked);
// alert(
("#pdfExport").click(function () {
//alert("clicked");
//alert(
(#jqxgrid1)。 jqxGrid);
var pdf = new jsPDF('p','pt','letter');
source =
("#jqxgrid1").jqxGrid);
var pdf = new jsPDF('p', 'pt', 'letter');
source =
这篇关于使用javascript从jqgrid下载PDF数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!