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

时间:2022-09-23 21:41:04

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

我正在使用“json”从db中提取数据。如何获取特定列的所有值。

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" i.e. giving me the value those are in current page.

这段代码只给我一个“PrimarySkill”的子集,即给我当前页面中的值。

I want full set value.

我想要全套价值。

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

1 个解决方案

#1


6  

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.

如果你有纯服务器端网格(数据类型:“xml”或数据类型:“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. So you can get the data using

如果使用本地网格或远程网格,服务器一次返回所有数据(使用loadonce:true),则数据将保存在jqGrid的内部_index和数据参数中。所以你可以使用

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

#1


6  

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.

如果你有纯服务器端网格(数据类型:“xml”或数据类型:“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. So you can get the data using

如果使用本地网格或远程网格,服务器一次返回所有数据(使用loadonce:true),则数据将保存在jqGrid的内部_index和数据参数中。所以你可以使用

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