简体   繁体   English

无论分页如何,JQGrid都会获取特定列的所有值

[英]JQGrid get all value for a particular column irrespective of paging

I am using "json" to pull data from db. 我正在使用“json”从db中提取数据。 How can I get all value for a particular column. 如何获取特定列的所有值。

I want to get all value/full set of value for "PrimarySkill" column irrespective of paging. 我想获得“PrimarySkill”列的所有值/全值,而不管分页。

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

This code only giving me a subset of "PrimarySkill" ie giving me the value those are in current page. 这段代码只给我一个“PrimarySkill”的子集,即给我当前页面中的值。

I want full set value. 我想要全套价值。

在此输入图像描述

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. 如果你有纯服务器端网格( datatype: "xml"datatype: "json"而你不使用loadonce: true )那么jqGrid没有关于其他页面数据的信息作为当前页面。

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. 如果您使用本地网格或远程网格,其中服务器一次返回所有数据 (使用loadonce: true ),则数据将保存在jqGrid的内部_indexdata参数中。 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));

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 如果你需要格式为{id:rowid, value:cellvalue} (比如getCol其中为true作为第二个参数)那么代码可能如下所示

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));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM