title: beforeRequest event jqGrid: set jqGrid page before url is called
body: <p>I am trying to set the page variable in jqGrid before the GET request to the URL...</p>
  
  <pre><code>        jQuery("#frTable").jqGrid({                
              cmTemplate: { sortable: false },
              caption: '@TempData["POPNAME"]' + ' Population',
              datatype: 'json',                
              mtype: 'GET',
              url: '/Encounters/GetAjaxPagedGridData/',
  </code></pre>
  
  <p>I have tried all sorts of things and I can't seem to get this to work no matter what I try...
  I have tried all sorts of things and the only thing that 'sort-of' worked was subscribing to the LoadComplete event like so...</p>
  
  <pre><code>            loadComplete: function() {
                  if ((rowFromTemp != "") &amp;&amp; (pageFromTemp != "")) {
                      setTimeout(function () {
                      $("#frTable").trigger("reloadGrid", [{page: pageFromTemp, rowNum: rowFromTemp}]); 
                      }, 50);
                  }
              },
  </code></pre>
  
  <p>the only problem that I had with that was that it was constantly updating.  Not sure why that would happen.  The only thing I figure there is that I am somehow looping with my timeout function...</p>
  
  <p>I have tried subscribing to a couple of other requests but each of those seems to fail.  The most promising I felt was the beforeRequest event.  This is what I currently have...</p>
  
  <pre><code>            beforeRequest: function() {
                  if ((rowFromTemp != "") &amp;&amp; (pageFromTemp != "")) {
                      $("#frTable").setGridParam([{ page: pageFromTemp, rowNum: rowFromTemp }]);                        
                      }
              },
  </code></pre>
  
  <p>It doesn't care what the heck I set the variables to, It just opens up on page 1 NO MATTER WHAT.<br>
  Now, I here that you can set the data to 'local' and that means that you have to reload the grid to get any data.</p>
  
  <p>But I want the data to load when a user first opens it up.  I am trying to set the page so that after a user edits a row with my edit screen, when he hits save, he will be taken back to the page that he was just on.  Not the first page.  As you know, that would be very frustrating for a user.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Ok... I put an alert in my beforeRequest event, and it fired before my grid loaded. Setting a break point in my action that is called in the url section tells me that the alert is called before I actually make the request.  Which is what I am hoping for.  I just need to figure out how to properly set the page variable.</p>
  
  <p><strong>UPDATE 2</strong>
  Ok.  I set the variable, and I had my alert show me that the variable was indeed set...</p>
  
  <pre><code>            beforeRequest: function() {
                  if ((rowFromTemp != "") &amp;&amp; (pageFromTemp != "")) {
                      this.p.page = pageFromTemp;
                      alert("This is what the page is: " + this.p.page + ";  And this is what I want it to be: \n" + pageFromTemp + " How do I get it there \n");
  </code></pre>
  
  <p>However, it still loads the first page?  So obviously, it is getting overridden again.  Why?  How can I set this permanently. </p>