这个.p是未定义的jqgrid
我有一个有趣的问题。我已经用多个网格在多个页面上完成了这项工作。第一个网格工作正常,第二个网格在这种情况下无法加载。并给出以下错误: 这个.p是未定义的 …sArray(i)){p=true;h=“last”;U=f}else{i=[i];p=false}this.each(function(){var D=i.l.…第140行jquery.jqGrid.min.js 用户doble单击一行并设置一些变量,然后调用函数locationGrid() 正如我所说,这在过去对我有效过多次,但在本页上它失败了。我已进行了双重检查,我正在恢复数据,如下所示: {“d”:“{“total\”:1,“page\”:0,“records\”:1,“rows\”:[{“invPartLocId\”:1053,“inventoryMasterId\”:5,“location\”:null,“itemType\”:“S\”,“currentQanity\”:1,“AdjustedQanity\”:0,“newLocationQty\”:0,“deptCode\”:“1401\”} 任何帮助都将不胜感激这个.p是未定义的jqgrid,jqgrid,Jqgrid,我有一个有趣的问题。我已经用多个网格在多个页面上完成了这项工作。第一个网格工作正常,第二个网格在这种情况下无法加载。并给出以下错误: 这个.p是未定义的 …sArray(i)){p=true;h=“last”;U=f}else{i=[i];p=false}this.each(function(){var D=i.l.…第140行jquery.jqGrid.min.js 用户doble单击一行并设置一些变量,然后调用函数locationGrid() 正如我所说,这在过去对我有效过多次,但在本页上它
function locationGrid() {
$('#invLocAdjustGrid').jqgrid({
height: 290,
loadui: "block",
datatype: function (rdata) { getLocationData(rdata); },
colNames: ['invPartID', 'locationPartID', 'Loctaion', 'Type', 'Current QTY', 'Adjusted QTY', 'New Location QTY', 'Dept. Code'],
colModel: [
{ name: 'invPartLocId', width: 2, sortable: false, editable: false, hidden: true },
{ name: 'inventoryMasterId', width: 2, sortable: false, editable: false, hidden: true },
{ name: 'location', width: 250, editable: false, sortable: false },
{ name: 'itemType', width: 120, editable: false, sortable: false, align: 'center' },
{ name: 'currentQanity', width: 50, editable: false, sortable: false },
{ name: 'adjustedQauntity', width: 50, editable: false, sortable: false },
{ name: 'newLocationQty ', width: 50, editable: false, sortable: false },
{ name: 'deptCode', width: 50, editable: false, sortable: false }
],
pager: jQuery('#rptCodesPager'),
viewrecords: true,
width: 890,
gridComplete: function () {
$('#load_invLocAdjustGrid').hide();
$(this).prop('p').loadui = 'enable';
$('#lui_invLocAdjustGrid').hide();
},
afterInsertRow: function (rowid, aData) {
},
ondblClickRow: function (rowid) {
var myID = $('#invLocAdjustGrid').getCell(rowid, 'invPartLocId');
Ldclicked(myID);
}
});
}
function getLocationData(rdata) {
var theID = tempID;
tempID = "";
var myDTO = { 'id': theID };
var toPass = JSON.stringify(myDTO);
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "INV_Inventory_Adjustment.aspx/getInventoryLocationById",
data: toPass,
success: function (data, textStatus) {
if (textStatus == "success")
ReceivedLocationData(JSON.parse(getMain(data)).rows);
},
error: function (data, textStatus) { alert('An error has occured retrieving data!'); }
});
}
function ReceivedLocationData(data) {
var thegrid = $('#invLocAdjustGrid');
var isGood = data.length;
for (var i = 0; i < isGood; i++) {
thegrid.addRowData(i + 1, data[i]);
}
}
函数locationGrid(){
$('#invLocAdjustGrid').jqgrid({
身高:290,
loadui:“块”,
数据类型:函数(rdata){getLocationData(rdata);},
colNames:['invPartID','locationPartID','Location','Type','Current QTY','Adjusted QTY','New Location QTY','Dept.Code'],
colModel:[
{name:'invPartLocId',宽度:2,可排序:false,可编辑:false,隐藏:true},
{name:'inventoryMasterId',宽度:2,可排序:false,可编辑:false,隐藏:true},
{name:'location',width:250,editable:false,sortable:false},
{name:'itemType',width:120,editable:false,sortable:false,align:'center'},
{name:'currentQanity',宽度:50,可编辑:false,可排序:false},
{name:'AdjustedQanity',宽度:50,可编辑:false,可排序:false},
{name:'newLocationQty',宽度:50,可编辑:false,可排序:false},
{name:'deptCode',宽度:50,可编辑:false,可排序:false}
],
寻呼机:jQuery(“#rptCodesPager”),
viewrecords:是的,
宽度:890,
gridComplete:函数(){
$(“#加载_invLocAdjustGrid”).hide();
$(this.prop('p')。loadui='enable';
$('lui#u invLocAdjustGrid').hide();
},
afterInsertRow:函数(rowid,aData){
},
ondblClickRow:函数(rowid){
var myID=$('#invLocAdjustGrid').getCell(rowid,'invPartLocId');
ldid(myID);
}
});
}
函数getLocationData(rdata){
var theID=tempID;
tempID=“”;
var myDTO={'id':theID};
var toPass=JSON.stringify(myDTO);
$.ajax({
键入:“POST”,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
url:“库存调整.aspx/getInventoryLocationById”,
数据:toPass,
成功:功能(数据、文本状态){
如果(textStatus==“成功”)
ReceivedLocationData(JSON.parse(getMain(data)).rows);
},
错误:函数(数据,textStatus){alert('检索数据时出错!');}
});
}
函数接收位置数据(数据){
var thegrid=$(“#invLocAdjustGrid”);
var isGood=data.length;
对于(var i=0;i
很抱歉,您的代码有缺陷。此外,我建议您重写整个代码,并尝试解释原因
第一个重要错误是您在locationGrid
中使用$('.\invLocAdjustGrid').jqgrid({…})
而不是$('.\invLocAdjustGrid')。jqgrid({…})
.JavaScript区分大小写,因此使用jqgrid
而不是jqgrid
非常重要
存在下一个问题,因为您使用了一些未在发布的代码中定义的变量和函数tempID
、Ldclicked
和getMain
在做了最小的修改之后,我只注释了“POST”以使用httpget,因为我直接从文件中获取JSON,并且在web服务器上没有活动组件
您清楚的另一个问题是,您的服务器代码将结果序列化了两次。通常情况下,由于错误使用ASMX WebMethods,您会遇到此问题。您不应该手动将对象转换为JSON。相反,您只需返回对象本身。由于此问题,t的d
属性JSON不是对象本身,而是一个字符串,应该再次进行解析:
{
“d:“{\'total\':1,\'page\':0,\'records\':1,\'rows\':[{\'invPartLocId\':1053,\'inventoryMasterId\':5,\'location\':null,\'itemType\':\'S\',\'currentQanity\':1,\'adjustedqanity\'0,\'newLocationQty\':0,\'deptCode\':'1401\'}”
}
jqGrid甚至可以读取格式错误的数据,而无需使用datatype
作为函数。此外,您应该始终使用gridview:true
,永远不要使用afterInsertRow
,也几乎永远不要使用addRowData
。修改后的代码可以是以下内容:
var tempID=“abc”;
$('#invLocAdjustGrid').jqGrid({
url:“库存调整.aspx/getInventoryLocationById”,
mtype:“POST”,
数据类型:“json”,
postData:{
id:function(){return tempID;}/???我不知道应该发送哪些数据
},
ajaxGridOptions:{contentType:“application/json”},
serializeRowData:函数(数据){
返回JSON.stringify(数据);
},
预处理前:函数(数据){
$.extend(true,data,$.parseJSON(data.d));
},
jsonReader:{repeatitems:false},
有一次:是的,
colNames:['invPartID