JQGrid gets all the value for a particular column regardless of paging

I am using "json" to output data from db. How can I get all the value for a specific column.

I want to get all value / complete set of values ​​for column "PrimarySkill" regardless of paging.

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

      

This code only gives me a subset of "PrimarySkill", that is, it gives me the value that is on the current page.

I need the complete setpoint.

enter image description here

+3


source to share


1 answer


If you have a clean server side grid (with datatype: "xml"

or datatype: "json"

, and you are not using loadonce: true

) then jqGrid has no information about the data of other pages as the current page.

If you are using local grid or remote grid where the server returns all data at once ( loadonce: true

), the data is stored in internal parameters _index

and data

jqGrid. So you can get data with

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

alert (JSON.stringify(myPrimarySkill));

      



If you need to have data in a format {id:rowid, value:cellvalue}

(for example, getCol

with true

as the second parameter), then the code might look like this:

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

      

+6


source







All Articles