JQGrid获得特定列的所有值,而与分页无关 [英] JQGrid get all value for a particular column irrespective of paging

查看:93
本文介绍了JQGrid获得特定列的所有值,而与分页无关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用"json"从数据库中提取数据. 如何获取特定列的所有值.

I am using "json" to pull data from db. How can I get all value for a particular column.

我想获取"PrimarySkill"列的所有值/全部值,而与分页无关.

I want to get all value/full set of value for "PrimarySkill" column irrespective of paging.

var texts = $("#listTableSupply").jqGrid('getCol', 'PrimarySkill');

此代码仅给我一部分"PrimarySkill",即为我提供当前页面中的值.

This code only giving me a subset of "PrimarySkill" i.e. giving me the value those are in current page.

我想要完整的设定值.

推荐答案

如果您具有纯服务器端网格(使用datatype: "xml"datatype: "json"并且未使用loadonce: true),则jqGrid将不具有有关其他页面的数据作为当前页面.

If you have pure server side grid (with datatype: "xml" or datatype: "json" and you don't use loadonce: true) then jqGrid have no information about the data of other pages as the current page.

如果您使用本地网格或远程网格,其中服务器一次返回所有数据(使用了loadonce: true),则数据将保存在jqGrid的内部_indexdata参数中.这样您就可以使用

If you use local grid or remote grid where the server returns all data at once (loadonce: true are used) then the data are saved in internal _index and data parameters of jqGrid. So you can get the data using

var mydata = $("#listTableSupply").jqGrid("getGridParam", "data"),
    myPrimarySkill = $.map(mydata, function (item) { return item.PrimarySkill; });

alert (JSON.stringify(myPrimarySkill));

如果您需要格式为{id:rowid, value:cellvalue}的数据(例如getCol,其中true作为第二个参数),则代码可能类似于以下内容

If you need to have the data in the format {id:rowid, value:cellvalue} (like getCol with true as the second parameter) then the code could be like the following

var mydata = $grid.jqGrid("getGridParam", "data"),
    ids = $grid.jqGrid("getGridParam", "_index"),
    myPrimarySkillWithIds = $.map(ids, function (index, key) {
        return { id: key, value: mydata[index].PrimarySkill };
    });

alert (JSON.stringify(myPrimarySkillWithIds));

这篇关于JQGrid获得特定列的所有值,而与分页无关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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