title: How to Save data to DB after editing or adding rows in jqgrid
body: <p>I have been trying to follow demos of <a href="http://www.trirand.com/blog/jqgrid/jqgrid.html" rel="nofollow">http://www.trirand.com/blog/jqgrid/jqgrid.html</a>, Row Edidting and Live Data Manipulation. I am able to edit rows, save them temporarily in jqgrid and able to get the popup window to add new row.</p>
  
  <p>I am populating my jqgrid with json objects.</p>
  
  <p>1) While doing edit in rows, using below code</p>
  
  <pre><code>onSelectRow: function(rowid, status) {                  
       if(rowid &amp;&amp; rowid!==lastsel){ 
           if (lastsel != null &amp;&amp; !myRowIsValid(lastsel) ) {
               return;
           }                               
           jQuery("#grid").saveRow(lastsel,true,'clientArray');  
           jQuery('#grid').jqGrid('editRow',rowid,true); 
           lastsel=rowid; 
       } 
  </code></pre>
  
  <p>},   </p>
  
  <p>After pressing Enter or selecting some other row, I can see that my last selected row is holding what I had entered. But how to save all edidted data back to DB??</p>
  
  <p>2)  By using below code to add new row into jqgrid, I am able to get the popup where I see all my columns. But when I press submit, after filling data, I get 'error status 'not found'. error code 404' at top of the window.</p>
  
  <pre><code>jQuery("#bedata").click(function(){
      jQuery("#grid").jqGrid('editGridRow',"new",{
          height:420,             
          reloadAfterSubmit:false,                
          closeAfterAdd:false,
          errorTextFormat:"Something Went Wrong",
          afterSubmit : function(response,postdata){ 
            alert("hi");
          }
      });         
  }); 
  </code></pre>
  
  <p>Note :-  I have editUrl:"/somejsp.html" in jQuery("#grid").jqGrid({...}) piece of code and corresponding to this I have one controller ready in my Spring MVC Controller class.</p>
  
  <p>I have seen lot of posts where people are saving data back to DB. But my problem is, in almost every post they are using PHP. I do not work in PHP. Could any body please tell me that how to add rows in grid temporarily and at last press one button and save all newly added or edited rows back to DB at once. </p>
  
  <p>But first what am I doing wrong while adding new row?</p>
  
  <p>Please let me know, if you want any other information.</p>