如何获取json格式的jqGrid过滤数据? [英] How to get jqGrid filtered data in json format?

查看:370
本文介绍了如何获取json格式的jqGrid过滤数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在控制器中获取jqGrid的数据.我正在使用此获取jqGrid的所有数据

I want to get data of jqGrid in my controller. I am getting all data of jqGrid using this

$("#gridSourceKey").jqGrid('getGridParam', 'data')

,但我希望以JSON格式过滤数据.我怎么能得到它?

but I want filtered data in JSON format. How can I get it?

推荐答案

旧版本的jqGrid(您使用的jqGrid 4.3.2)无法获取过滤后的数据.因此,您必须升级到免费jqGrid 并使用

The old version of jqGrid (jqGrid 4.3.2, which you use) provides no possibility to get filtered data. So you have to upgrade to free jqGrid and just use

$("#gridSourceKey").jqGrid('getGridParam', 'lastSelectedData')

代替

$("#gridSourceKey").jqGrid('getGridParam', 'data')

仅当您确实无法更新所使用的jqGrid 时,才应遵循答案.该解决方案包括三个步骤:1)将原始内部jqGrid函数$.jgrid.from覆盖(子类化)为该函数,该函数将最后的过滤结果保存在局部lastSelected变量中. 2)loadComplete,它将结果从局部lastSelected变量放置到新的自定义jqGrid参数lastSelected. 3)$("#gridSourceKey").jqGrid('getGridParam', 'lastSelected')的用法.

Only if you really can't update jqGrid which you use then you should follow the tricky solution described in the answer. The solution consist from three steps: 1) overwriting (subclassing) the original internal jqGrid function $.jgrid.from to the function which saves the last filtering results in local lastSelected variable. 2) loadComplete which places the results from the local lastSelected variable to new custom jqGrid parameter lastSelected. 3) the usage of $("#gridSourceKey").jqGrid('getGridParam', 'lastSelected').

这篇关于如何获取json格式的jqGrid过滤数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆