title: execute oncellselect from jqgrid triggered by button click event
body: <p>I want to be able to get an ID value from a row in a jqGrid when a button click event occurs that is not bound to the grid.</p>
  
  <p>In other words, if a user has a row selected on the grid and also clicks a button not associated with the grid, I'd like the onCellSelect event to be fired where that button click event could pass down the ID retrieved from the grid (via the onCellSelect event).</p>
  
  <p>So, here would be a sample of the code I'm trying to execute, but don't know how to wire this up. If someone could please help, I would greatly appreciate it.</p>
  
  <pre><code> $('#btnSPStop').on('click', function (e)
      {
      // Somehow, I need to fire an event here (similiar to below) where I can retrieve the selected grid row 
      onCellSelect: function (rowid, iCol, cellcontent) {
                      var grid = $('#fuelTicketsGrid');
                      var ID = grid.jqGrid('getCell', rowid, 'ID');
                      if (ID != "")
                          saveStopComments(ID);
              else
              alert("User must first have row selected in grid!");
                  },
  
          return false;
      });
  </code></pre>
  
  <h2>EDIT # 1</h2>
  
  <p>Oleg, after implementing your code, I get the following error message:
  <img src="https://i.stack.imgur.com/Np2do.png" alt="enter image description here"></p>
  
  <p>I get a valid "selRowId" when debugging and selecting the second row in the grid (ie a "2").</p>
  
  <p>I checked the JS for the jqGrid and "rowid" is defined. <strong>Am I missing something on the definition of the grid that I need to include for the rowed to be defined?</strong></p>
  
  <p>I get the error on the below line:</p>
  
  <pre><code>ID = grid.jqGrid('getCell', rowid, 'ID');
  </code></pre>
  
  <p>This is the entire modified function:</p>
  
  <pre><code>$('#btnSPStop').on('click', function (e)
      {
          var grid = $('#StopPenalizeGrid-table'), ID,
          selRowId = grid.jqGrid('getGridParam', 'selrow');
  
          if (selRowId !== null)
          {
              ID = grid.jqGrid('getCell', rowid, 'ID');
              if (ID != "")
                  $('#txtStopGridID').val(ID);
              else
                  alert("You must have a row selected on the grid before clicking the Stop button!");
          }
          else
              alert("selRowId is equal to null for btnSPStop onClick method.");
  
          return false;
      });
  </code></pre>