title: how to persist current row in jqgrid
body: <p>How to presist current row if grid is opened again or page is refreshed ?</p>
  
  <p>Answer in <a href="https://stackoverflow.com/questions/8422878/persisting-jqgrid-column-preferences">Persisting jqGrid column preferences</a> describes how to persist column width and some other parameters.</p>
  
  <p>In this answer demo I clicked in some row and pressed F5 . Previous clicked row was not highlighted.
  How to save / restore current row in local storage ?</p>
  
  <p><strong>Update</strong></p>
  
  <p>If jqGrid column structure is modified in application and user opens application from browser again,
  restorecolumnstate creates invalid colmodel where some elements are missing. This causes exception in refreshSearchingToolbar which assumes that all colmodel elements are present.</p>
  
  <p>How to fix this ? How to dedect modified colmodol and not to restore colmodel in this case ? Or should restoreColumnState update colModel so that proper array is created ? </p>
  
  <p>**Update 2 **</p>
  
  <p>If myColumnsState.permutation contains nulls <code>$grid.jqGrid("remapColumns", myColumnsState.permutation, true)</code> created invalid colmodel. Here are screenshots from VS debugger immediately before and after remapColumns call</p>
  
  <p><img src="https://i.stack.imgur.com/ZahWR.png" alt="enter image description here"> </p>
  
  <p>after:</p>
  
  <p><img src="https://i.stack.imgur.com/LMke4.png" alt="after"></p>
  
  <p>I fixed this by chaning code to </p>
  
  <pre><code>    if (isColState &amp;&amp; myColumnsState.permutation.length &gt; 0) {
          var i, isnull = false;
          for (i = 0; i &lt; myColumnsState.permutation.length; i = i + 1) {
              if (myColumnsState.permutation[i] == null) {
                  isnull = true;
                  break;
              }
          }
          if (!isnull) {
              $grid.jqGrid("remapColumns", myColumnsState.permutation, true);
          }
  </code></pre>
  
  <p>Is this best solution ?</p>