title: How to periodically reload jQGrid
body: <p>I am trying to reload my grid periodically. I came across the solution:</p>
  
  <pre><code>var grid = $("#list"),
      intervalId = setInterval(
      function() {
          grid.trigger("reloadGrid",[{current:true}]);
      },
      300000); // 300 sec === 5 min
  </code></pre>
  
  <p>but i'm not sure where to put this piece of code. does it go inside <code>loadComplete</code> ? I am already using </p>
  
  <pre><code>jQuery("#list").trigger("reloadGrid", [{current:true}]);
  </code></pre>
  
  <p>like this </p>
  
  <pre><code>jQuery("#list").jqGrid({...
  
      jQuery("#list").trigger("reloadGrid", [{current:true}]);
  
  ...});
  </code></pre>
  
  <p>i dont understand where to access the </p>
  
  <pre><code>intervalId
  </code></pre>
  
  <p>please help,.
  thanks</p>
  
  <p>Oleg, this is what i tried as per your answer:</p>
  
  <pre><code>    // above this line is the grid code including nav grid
  
      jQuery("#refresh_list").click(function(){
          jQuery("#list").setGridParam({datatype: 'json'});
        //  jQuery("#list").trigger("reloadGrid");
        setInterval(function() {
              $('#list').trigger("reloadGrid", [{current:true}]);
          alert("hello");}, 2000);
              });
      });   //This is the end of the document.ready function
  </code></pre>
  
  <p>am I placing the setinterval function correctly ? is it supposed to be inside the grid or outside ? is it supposed to be inside the document.ready or outside ?
  <strong>surprisingly, the alert pops up as you would expect !</strong> but the grid does not reload. i know because i am making changes to the database and they are not reflected in the grid. when i click the refresh button then it displays current data as expected. I want it to reload periodically and always have the most recent data from the database.</p>
  
  <p>by the way these are the gridoptions i am using </p>
  
  <pre><code>    pager: "#pager",        //Identifying the navigation bar
    rowNum: 500,          // how many rows to display on page 1
    rowList: [500,1000, 2000, 3000,4000], //values for the dropdown which specifies how many rows to show 
    sortorder: "desc", //the order of sorting by default
    viewrecords: true, // displays total number of rows
    gridview: true,   // the full grid body will be placed on the page as one operation
    autoencode: true,
    height:400, //height of the grid
    ignoreCase:true,// case insensitive search
    multiselect:true, // checkboxes before each row
    multiboxonly: true,
    loadonce:true, //for client side sorting, searching and pagination
    caption:"This is me", // caption for the grid header
  </code></pre>
  
  <p>please help</p>