简体   繁体   中英

JQGrid get all value for a particular column irrespective of paging

I am using "json" to pull data from 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.

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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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