Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

servlets - Export jqgrid filtered data as excel or CSV

I am in trouble please help me out.I want to show "export to excel" button in the pager of jqgrid, that will export the current set of data which is retrieve after searching criteria of jqgrid (based on the current filter). I am using "loadonce:true" setting for my jqgrid.Now I want to export data from local datasource of jqgrid after searching. If it is not possible then how I can able to pass parameters to a server when I click on export button of navigation on which searching criteria need to do. I am using back-end as a servlet.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I would recommend you to implement export of data on the server and just post the current searching filter to the back-end. Full information about the searching parameter defines postData parameter of jqGrid. Another boolean parameter of jqGrid search define whether the searching filter should be applied of not. You should better ignore _search property of postData parameter and use search parameter of jqGrid.

Format of the information about the searching filter depend on whether use used multipleSearch: true option. I personally use it always. In the case the full information about the filter will be placed in one property of the postData parameter: filters property. The format is described here. The code which gets the information looks like the following

var $grid = $("#list"),
    isFilterAreUsed = $grid.jqGrid('getGridParam', 'search'),
    filters = $grid.jqGrid('getGridParam', 'postData').filters;

If you don't use multipleSearch: true option you will be not able to use complex filters and the information about the filter will be placed in three properties of the postData parameter: searchField, searchOper and searchString.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...