当我点击添加模式中的取消按钮时,我在jquery.jqGrid.js文件中收到以下错误:
" 0x800a138f - JavaScript运行时错误:无法获取属性' a'未定义或空引用"
我只在Internet Explorer中收到此错误,Chrome工作正常。
我遇到的第二个问题是我从按钮调用添加模式:
<button name="addbutton" id="addbutton" class="add-new-row btn btn-success addbutton" style="float:right; margin-top:1%; margin-left:1%;">Add</button>
然后在网格JS文件中使用以下代码:
$(".addbutton").on("click", function () {
$("#grid").editGridRow("new",
{
// add options
//2lines added by Ilango
top: 50, left: 100, width: 500,
addCaption: "Add record Dialog",
addParams: { position: "afterSelected" },//, addRowParams: editOptions
zIndex: 100,
url: "/Transactions/Create",
closeOnEscape: true,
closeAfterAdd: true,
reloadAfterSubmit: true,
afterComplete: function (response) {
if (response.responseText) {
$('#grid').trigger('reloadGrid')
// alert(response.responseText);
//window.location.reload();
//reDefineColWidth();
// $('#grid').trigger('reloadGrid')
window.history.back();
}
},
//submit on enter key
onInitializeForm: function ($form) {
$("td.DataTD>.FormElement", $form).keypress(function (e) {
if (e.which === $.ui.keyCode.ENTER) {
$("#sData", $form.next()).trigger("click");
return false;
}
});
},
//adjust position of add form modal
beforeShowForm: function (form) {
//alert('adding' + "#editmod" + grdNames[0].id);
//var dlgDiv = $("#editmod" + grdNames[0].id);
var dlgDiv = $("#editmod" + $('#grid')[0].id);
//var dlgDiv = jQuery("#editmodgrid");
var parentDiv = dlgDiv.parent(); // div#gbox_list
var dlgWidth = dlgDiv.width();
var parentWidth = parentDiv.width();
var dlgHeight = dlgDiv.height();
var parentHeight = parentDiv.height();
// Grabbed jQuery for grabbing offsets from here:
//http://stackoverflow.com/questions/3170902/select-text-and-then-calculate-its-distance-from-top-with-javascript
var parentTop = parentDiv.offset().top;
var parentLeft = parentDiv.offset().left;
// HINT: change parentWidth and parentHeight in case of the grid
// is larger as the browser window
dlgDiv[0].style.top = Math.round(parentTop + (parentHeight - dlgHeight) / 2) + "px";
//400 offset from left
dlgDiv[0].style.left = Math.round(parentLeft + 500 + (parentWidth - dlgWidth) / 2) + "px";
},
afterShowForm: function (form) {
//alert('adding' + "#editmod" + grdNames[0].id);
//var dlgDiv = $("#editmod" + grdNames[0].id);
var dlgDiv = $("#editmod" + $('#grid')[0].id);
//var dlgDiv = jQuery("#editmodgrid");
var parentDiv = dlgDiv.parent(); // div#gbox_list
var dlgWidth = dlgDiv.width();
var parentWidth = parentDiv.width();
var dlgHeight = dlgDiv.height();
var parentHeight = parentDiv.height();
// Grabbed jQuery for grabbing offsets from here:
//http://stackoverflow.com/questions/3170902/select-text-and-then-calculate-its-distance-from-top-with-javascript
var parentTop = parentDiv.offset().top;
var parentLeft = parentDiv.offset().left;
// HINT: change parentWidth and parentHeight in case of the grid
// is larger as the browser window
dlgDiv[0].style.top = Math.round(parentTop + (parentHeight - dlgHeight) / 2) + "px";
//400 offset from left
dlgDiv[0].style.left = Math.round(parentLeft + 500 + (parentWidth - dlgWidth) / 2) + "px";
},
});
});
当我单击提交按钮时,记录已提交,但仅提供我为每列设置的默认值,而不是我在模式中输入的值。我没有使用内置的导航添加按钮来解决这个问题。
请帮忙!我花了很多很多小时试图解决这个问题。
修改
如果(!h.a):
,则出现错误的代码块 close:function(s){var h=H[s];if(!h.a)return F;h.a=F;
if(A[0]){A.pop();if(!A[0])L('unbind');}
if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F;
}