我有三个jqxgrids调用相同的函数来创建一个新帐户(这是一个jq ui对话框)。区分调用哪个网格的最简单或最好的方法是什么。
我的代码:
$("#divNewAccountDetails").dialog({
autoOpen: F,
modal: T,
title: "New Account",
width: 600,
close: function () {
},
buttons: {
"Save & Close": function () {
$(this).dialog("close");
var _Object, indexes, _row1, _row2, _row3;
_Object = $("#jqxAccountDropdownGrid");
indexes = $(_Object).jqxGrid('selectedrowindexes');
for (var index in indexes) {
_row1 = $(_Object).jqxGrid('getrowdata', index);
if (typeof _row1["AccountName"] !== "undefind") {
if (_row1["AccountName"].toString().toLowerCase() === "new") {
alert("Account");
$(_Object).jqxGrid('clearselection');
break;
}
}
}
_Object = $("#jqxPurchaseAccountDropdownGrid");
indexes = $(_Object).jqxGrid('selectedrowindexes');
for (var index in indexes) {
_row2 = $(_Object).jqxGrid('getrowdata', index);
if (typeof _row2["AccountName"] !== "undefind") {
if (_row2["AccountName"].toString().toLowerCase() === "new") {
alert("Purchase Account");
$(_Object).jqxGrid('clearselection');
break;
}
}
}
_Object = $("#jqxSalesAccountDropdownGrid");
indexes = $(_Object).jqxGrid('selectedrowindexes');
for (var index in indexes) {
_row3 = $(_Object).jqxGrid('getrowdata', index);
if (typeof _row3["AccountName"] !== "undefind") {
if (_row3["AccountName"].toString().toLowerCase() === "new") {
alert("Sales Account");
$(_Object).jqxGrid('clearselection');
break;
}
}
}
},
Cancel: function () {
$(this).dialog("close");
}
}
});
基本上,网格绑定到列更改,当列值为"new"
时,脚本会触发对话(上面的代码)。发生了什么事情,当我点击Save & Close
按钮时,我得到"Uncaught TypeError: Cannot read property 'toString' of undefined"
。我不明白的是,我正在使用逻辑测试检查未定义,它似乎正在执行if块,无论如何它不应该。
答案 0 :(得分:1)
我看到 undefined
的拼写错误。这可能是原因吗?我不确定。