[英]What is the easiest way to differentiate between function calls from three different jqxgrid calls?
我有三个 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"
。 我不明白的是我正在使用逻辑测试来检查 undefined 并且它似乎正在执行它不应该执行的 if 块。
我看到undefined
的拼写错误。 这可能是原因吗? 我不知道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.