Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my jqgrid Design Page code

HTML
<div id='jqxWidget1'>

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


This im my html Button

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



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>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
Posted
Updated 4-Apr-16 21:58pm
v2
Comments
itsathere 5-Apr-16 10:57am    
on button click call call controller action method using ajax/json. You will get many code on google search.I think, it will be better for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900