Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with sending all data to the server after local adding rows
    primarykey
    data
    text
    <p>Hi I am a newbie to jqGrid. I am using jqGrid 4.4. I have successfully used the approach by Oleg in </p> <p><a href="https://stackoverflow.com/questions/5611065/adding-new-row-to-jqgrid-using-modal-form-on-client-only/5611519#5611519">Adding new row to jqGrid using modal form on client only</a></p> <p>to add rows locally. There are 2 issues I am facing </p> <ol> <li>The row that is not added to the end , how can I achieve this?</li> <li>I send all the rows on click of a button as below:</li> </ol> <p>I always get the alert in the error block? </p> <pre><code> $("#sendButton").click(function(){ var gridData = jQuery("#list").getRowData(); var myJSONString = JSON.stringify(gridData); var postData = myJSONString.replace(/[\"]/g, '\"'); alert("JSON serialized jqGrid data:\n" + postData); $.ajax({ type: "POST", url: CONTEXT_ROOT+"/json", data : postData, dataType:"json", contentType: "application/json; charset=utf-8", success: function(response, textStatus, xhr) { alert("success"); }, error: function(xhr, textStatus, errorThrown) { alert("error:"+errorThrown+" textStatus : "+textStatus); } }); }); </code></pre> <p>Not sure what I need to return once I save in the java controller. Here is the code in the controller. I also tried with the return as void but same result. Also is there a better approach to bind the list of json objects coming from the jsp to a list of domain objects. I have tried Binding when there is only a single object like from the form using @RequestBody as explained in </p> <p><a href="http://blog.springsource.org/2010/01/25/ajax-simplifications-in-spring-3-0/" rel="nofollow noreferrer">http://blog.springsource.org/2010/01/25/ajax-simplifications-in-spring-3-0/</a></p> <pre><code>@RequestMapping(value = "/json", method = RequestMethod.POST) public ModelAndView saveNewCasePackOptions(@RequestBody List&lt;Map&gt; json) { for(Map mJson : json){ String idCasePkOptions = (String)mJson.get("idCasePackOptions"); Long idCasePackOptions = (idCasePkOptions.isEmpty())?null:new Long(idCasePkOptions); Short cypharecommended = new Short((String)mJson.get("cypharecommended")); Short distributorapproved = new Short((String)mJson.get("distributorapproved")); String heightStr = (String)mJson.get("height"); Double height = (heightStr.isEmpty())?null:new Double(heightStr); String lengthStr = (String)mJson.get("length"); Double length = (lengthStr.isEmpty())?null:new Double(lengthStr); String weightStr = (String)mJson.get("height"); Double weight = (weightStr.isEmpty())?null:new Double(weightStr); String widthStr = (String)mJson.get("width"); Double width = (widthStr.isEmpty())?null:new Double(widthStr); String stateString = (String)mJson.get("statuscode"); stateString = (stateString.contains("Green"))?"1":"0"; Short statuscode = new Short(stateString); CasePackOptions casePkOpt = new CasePackOptions(idCasePackOptions, cypharecommended, distributorapproved, height, length, statuscode, weight, width); System.out.println(casePkOpt); casePackOptionsService.save(casePkOpt); } ModelAndView mav = new ModelAndView(); mav.setViewName("casepackoptions/listPage1.jsp"); return mav; } </code></pre> <p>Any help will be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload