title: What is the easiest way to differentiate between function calls from three different jqxgrid calls?
body: <p>I have three jqxgrids that call the same function to create a new account (which is a jq ui dialogue). What is the easiest or best way to differentiate between which grid was called.</p>
  
  <p>My code:</p>
  
  <pre><code>$("#divNewAccountDetails").dialog({
      autoOpen: F,
      modal: T,
      title: "New Account",
      width: 600,
      close: function () {
      },
      buttons: {
          "Save &amp; 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");
          }
      }
  });
  </code></pre>
  
  <p>So basically the Grids are bound to a column change and when that columns value is <code>"new"</code>, the script triggers the dialogue (code above). What is happening is that when I click the <code>Save &amp; Close</code> button, I get <code>"Uncaught TypeError: Cannot read property 'toString' of undefined"</code>. What I do not understand is that I am using a logic test to check for undefined and it appears to be executing the if block anyway which it shouldn't.</p>