Export function

Nov 15, 2012 at 8:56 AM
Edited Nov 15, 2012 at 9:05 AM

Hello,. Thanks for this libarry. I have one question.

How can I implement export to excel file?

PS. The export button locate outside of grid. This is simple <input type='button'>

Nov 15, 2012 at 11:52 AM


What you need to do is write some JavaScript which will download the file from server for you. There is nothing in the helper or jqGrid which can help with generating the file, so you will have to use one of standard techniques of creating Excel files:

You might need to get some current options from jqGrid if you want to export just current page or keep some filters - if that is the case please let me know what you need to get out of the grid and I will show you how to build and object in JavaScript which can be binded to JqGridRequest object on server side.

Nov 16, 2012 at 2:15 AM
Edited Nov 16, 2012 at 2:16 AM

Thanks for the answer.

I had to be more specific. I want to get JqGridRequest object on server side. Can you show me?


Nov 16, 2012 at 8:39 AM

Sure, I will sit down later tonight and post here a script that should help you.

Nov 16, 2012 at 4:06 PM

Thanks for the help.

Nov 16, 2012 at 7:48 PM

When jqGrid makes a request to the server it extends its internal `postData` option. It is enough for you to get value of this parameter and perform a standard get request to your action:

$('#<buttonId>').click(function(e) {
    //You need to perform a non AJAX get in order to download file
    window.location.href = '<your action url>?' + $.param($('#<gridId>').jqGrid('getGridParam', 'postData'));

If you make the JqGridRequest object a parameter of your action it should be binded properly.

Nov 17, 2012 at 8:52 AM

Big thanks. This is what I need.