将 jqgrid 过滤后的数据导出为 excel 或 CSV [英] Export jqgrid filtered data as excel or CSV
问题描述
我遇到麻烦请帮帮我.我想在 jqgrid 的寻呼机中显示导出到 excel"按钮,这将导出在 jqgrid 搜索条件后检索的当前数据集(基于当前过滤器).我正在为我的 jqgrid 使用loadonce:true"设置.现在我想在搜索后从 jqgrid 的本地数据源中导出数据.如果不可能,那么当我单击需要执行搜索条件的导航的导出按钮时,我如何能够将参数传递给服务器.我将后端用作 servlet.
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.
推荐答案
我建议你在服务器上实现数据的导出,把当前的搜索过滤器发布到后端.关于搜索参数的完整信息定义了 jqGrid 的 postData
参数.jqGrid search
的另一个布尔参数定义是否应该应用搜索过滤器.您最好忽略 postData
参数的 _search
属性并使用 jqGrid 的 search
参数.
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.
搜索过滤器信息的格式取决于是否使用了multipleSearch: true
选项.我个人一直使用它.在这种情况下,有关过滤器的完整信息将放在 postData
参数的一个属性中:filters
属性.格式在此处进行了描述.获取信息的代码如下所示
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;
如果您不使用 multipleSearch: true
选项,您将无法使用复杂的过滤器,并且有关过滤器的信息将放置在 postData
参数:searchField
、searchOper
和searchString
.
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
.
这篇关于将 jqgrid 过滤后的数据导出为 excel 或 CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!