当我尝试远程加载数据时,Jqgrid分组无法正常工作。它没有显示任何东西。 var $ grid = $(“#jqgrid-content”); var rawRowData = {};
function shortAddressFormatter(cellvalue, options, rowObject) {
rawRowData[rowObject._id] = rowObject;
return rowObject.Address["Address Line 1"];
}
function shortAddressLine2(cellvalue, options, rowObject) {
return (rowObject.Address["Address Line 1"] != '') ? rowObject.Address["Address Line 1"]: '';
}
function contactName(cellvalue, options, rowObject){
return rowObject.Address.Name;
}
function city(cellvalue, options, rowObject){
return rowObject.Address.City;
}
function state(cellvalue, options, rowObject){
return rowObject.Address.State;
}
function country(cellvalue, options, rowObject){
return rowObject.Address.Country;
}
function postalCode(cellvalue, options, rowObject){
return rowObject.Address["Postal Code"];
}
function businessHoursPhoneFormatter(cellvalue, options, rowObject) {
return rowObject.Address["Business Hours Phone"];
}
function afterHoursPhoneFormatter(cellvalue, options, rowObject) {
return rowObject.Address["After Hours Phone"];
}
function groupChar(cellvalue, options, rowObject){
var grp_char = rowObject.Address.Name.charAt(0);
return grp_char;
}
映射到jqgrid
$grid.jqGrid({
datatype: "json",
url:"addressList.php",
height: '100%',
width:null,
autowidth: true,
scrollOffset:0,
rowNum: 30,
rowList: [10, 20, 30],
colNames:['Id','Group By','Name','Address Lin1','Address Lin2','City','State','Postal_Code','Country','Business Hours Phone','After Hours Phone'],
colModel: [
{name:'_id',index:'_id', hidden:true },
{name:'grp_by',index:'grp_by', formatter:groupChar, width:180,hidden:true},
{name:'Address.Name',index:'Address.Name', formatter:contactName, width:140},
{name:'Address Line 1',index:'Address Line 1', width:180,hidden:true },
{name:'Address Line 2',index:'Address Line 2', formatter:shortAddressLine2, width:180,hidden:true},
{name:'City',index:'City', width:180,formatter:city,hidden:true},
{name:'State',index:'State', width:180,formatter:state ,hidden:true},
{name:'Postal_Code',index:'Postal Code', formatter:postalCode, width:180,hidden:true },
{name:'Country',index:'Country', width:180,formatter:country,hidden:true },
{name:'business_hours_phone',index:'business_hours_phone', width:180,formatter:businessHoursPhoneFormatter,hidden:true },
{name:'after_hours_phone',index:'after_hours_phone', width:180,formatter:afterHoursPhoneFormatter,hidden:true }
],
grouping: false,
sortname: 'grp_by',
groupingView: {
groupField: ['grp_by']
//groupColumnShow : [false]
},
pager: jQuery("#jqgrid-pager"),
viewrecords: true,
onCellSelect : function(rowid, iCol, cellcontent){
var loc_name = $grid.jqGrid('getCell', rowid,iCol);
//var loc_description = $grid.jqGrid('getCell', rowid,iCol);
var ph_address = $grid.jqGrid('getCell', rowid,iCol+2);
var ph_address2 = $grid.jqGrid('getCell', rowid,iCol+1);
var loc_city = $grid.jqGrid('getCell', rowid,iCol+3);
var loc_state = $grid.jqGrid('getCell', rowid,iCol+4);
var loc_zip = $grid.jqGrid('getCell', rowid,iCol+5);
var loc_phone_business = $grid.jqGrid('getCell', rowid,iCol+7);
var loc_phone_private = $grid.jqGrid('getCell', rowid,iCol+8);
$('#loc_name').val(loc_name);
//$('#loc_description').val(loc_description);
$('#ph_address').val(ph_address);
$('#ph_address2').val(ph_address2);
$('#loc_city').val(loc_city);
$('#loc_state').val(loc_state);
$('#loc_zip').val(loc_zip);
$('#loc_phone_business').val(loc_phone_business);
$('#loc_phone_private').val(loc_phone_private);
}
});
请帮我解决这个问题