Yugandhar Yugandhar - 5 months ago 65
Javascript Question

How to get key and values of particular of jqGrid

I have one jqGrid like below(part of the code)

$(function() {
options = $("#pdbconfiggrid").jqGrid({
url:URL,
datatype: 'json',
mtype: 'GET',
colNames:['Display Name','Property Name', 'Property Value', 'Group Type'],
colModel:[
{name:'display_name',index:'key',editable:false,sortable:false, width:30},
{name:'key',index:'_key', hidden:true},
{name:'value',index:'value', editable:false,sortable:false, width:100, formatter:returnPropertyValue},
{name:'group',index:'group',sortable:false, hidden:true, width:30},
],
postData: {},
rowNum: -1,
height: 'auto',
headertitles:true,
autowidth: true,
viewrecords: false,
toppager: false,
emptyrecords: "Empty records",
cmTemplate: { title: false},
loadonce: false,
altRows: true,
sortname: 'index',
sortorder: "asc",
grouping:true,
groupingView : {
groupField : ['group'],
groupColumnShow : [false],
groupCollapse : true,
groupSorted: false,
groupDataSorted: false
},


I am setting multiple group values(like A,B,C,D) for this grid.
Now , how can i get all key & values of particular group on given grop name
like jqGrid.getGroupData("A");

thanks

Answer

I have tried like this. and it works

  function getGroupData(group_name) {
var rowData;
var complete_data = jQuery("#syncconfiggrid").jqGrid('getRowData');
var group_data = {};
for (var index in complete_data) {
    rowData = complete_data[index];
    if (group_name == rowData.group) {
        var prop_key = rowData.key;
        if (null != prop_key && prop_key.length > 2)
            group_data[prop_key] = $('#' + prop_key.replaceAll(".", "_")).val(); // this is my code specific
    }
}
return group_data;
}