jQuery / jQgrid 코딩이 처음입니다. jQgrid 버전은 4.4.4 및 jQuery 1.8.3입니다. 내 jQgrid에서 PDF / EXCEL 기능으로 내보내기를 활성화하고 싶습니다. 이를 위해 다음 링크를 참조했습니다 . 여기 를 클릭 하고 여기 를 클릭하십시오 . 이 링크를 기반으로 jquery에서 다음과 같은 몇 줄의 코드를 개발했습니다.
.jqGrid('navGrid', topPagerSelector, { edit: false, add: false, del: false, search: false, pdf: true}, {}, {}, {}, {}
}).jqGrid('navButtonAdd',topPagerSelector,{
id:'ExportToPDF',
caption:'',
title:'Export To Pdf',
onClickButton : function(e)
{
try {
$("#tbPOIL").jqGrid('excelExport', { tag: 'pdf', url: sRelativePath + '/rpt/poil.aspx' });
} catch (e) {
window.location = sRelativePath + '/rpt/poil.aspx&oper=pdf';
}
},
buttonicon: 'ui-icon-print'
});
그러나이 코드는 제대로 작동하지 않습니다. 인터넷 Google에서 많이 검색했지만 내 작업을 수행하는 데 유용하고 관련성있는 정보를 얻지 못하고 있습니다. 누구든지 이것을하는 방법을 알고 있습니까 ???
업데이트 : 나는 jqgrid의 유료 버전을 사용하고 있지 않습니다.
onclick 이벤트 내에서 호출되는 함수입니다.
function exportGrid(){
mya = $("#" + table).getDataIDs(); // Get All IDs
var data = $("#" + table).getRowData(mya[0]); // Get First row to get the
// labels
var colNames = new Array();
var ii = 0;
for ( var i in data) {
colNames[ii++] = i;
} // capture col names
var html = "<html><head>"
+ "<style script="css/text">"
+ "table.tableList_1 th {border:1px solid black; text-align:center; "
+ "vertical-align: middle; padding:5px;}"
+ "table.tableList_1 td {border:1px solid black; text-align: left; vertical-align: top; padding:5px;}"
+ "</style>"
+ "</head>"
+ "<body style="page:land;">";
for ( var k = 0; k < colNames.length; k++) {
html = html + "<th>" + colNames[k] + "</th>";
}
html = html + "</tr>"; // Output header with end of line
for (i = 0; i < mya.length; i++) {
html = html + "<tr>";
data = $("#" + table).getRowData(mya[i]); // get each row
for ( var j = 0; j < colNames.length; j++) {
html = html + "<td>" + data[colNames[j]] + "</td>"; // output each Row as
// tab delimited
}
html = html + "</tr>"; // output each row with end of line
}
html = html + "</table></body></html>"; // end of line at the end
alert(html);
html = html.replace(/'/g, ''');
// var form = "<form name='pdfexportform' action='generategrid' method='post'>";
// form = form + "<input type='hidden' name='pdfBuffer' value='" + html + "'>";
// form = form + "</form><script>document.pdfexportform.submit();</sc"
// + "ript>";
// OpenWindow = window.open('', '');
// OpenWindow.document.write(form);
// OpenWindow.document.close();
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다