I am new in jQuery/jQgrid coding. I am using jQgrid version is 4.4.4 & jQuery 1.8.3. I want to enable export to PDF/EXCEL functionality in my jQgrid. For that I referred following links - Click Here and Click Here. On the basis of this links, I developed few lines of code in jquery which is as follows:
.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'
});
But this code is not working properly. I searched on internet google a lot but I am not getting useful & relevant info to achieve my task. Is anyone know how to do this???
UPDATE: I a am not using paid version of jqgrid.
Here is a clever solution to save the
jqGrid
data as excel sheet: (You just need to call this function withGridID
and an optionalFilename
)We first create a
CSV
string delimited with;
. Then ananchor
tag is created with certain attributes. Finallyclick
is called ona
to download the file.strong text
function to be called inside of your onclick event.
If you are on PHP, try phpGrid. Then you just need to call
check out http://phpgrid.com/example/export-datagrid-to-excel-or-html. It generates jqGrid javascript required for rendering grid.