@kirangentlebreeze1987 said:
aarati said:
Hello,Finally got it to work
.
Made slight modifications to the existing code:
Struts Action:
1) Earlier was returning to an empty jsp page with no specific code. Now returning null.
2) Using the write method of the jsonObj to write the response data.
The action method now looks like the following:
public ActionForward getJSONData(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response) {…
…
 JSONObject jsonObj = createJSONTestData();
System.out.println(“Final JSON OBj: ” + jsonObj.toString());Â
jsonObj.write(response.getWriter());
return null;
 }Â
JSP:
JSP Code to populate the grid is shown below:
$(document).ready(function(){
$.ajax(
   {
      type: “POST”,
      url:’  /TestJSON/testAction.do?method=getJSONData’,
      data: “”,
      dataType: “json”,
      success: function(result)
      {
           alert(“success”);
           alert(“result: ” + result.total);
           jQuery(“#list10”).jqGrid({
            url:’  /TestJSON/testAction.do?method=getJSONData’,
               datatype: ‘json’,
               mtype: ‘POST’,
               colNames:,
        colModel:[
            {name:’id’,index:’id’, id:’name’,width:90},
            {name:’invdate’,index:’invdate’, width:120},
            {name:’invname’,index:’invname’, width:200}
    ],
               pager: jQuery(‘#pager1’),
               rowNum: 5,
               rowList: [5, 10, 20, 50],
               viewrecords: true
           })
      },
      error: function(x, e)
      {
           alert(“errorddd ” + x.readyState + ” “+ x.status +” “+ e);
           if (x.readyState == 4) {
            var response = x.responseText;
            alert(response);
           }
      }
   });
setTimeout(function() {$(“#list10”).jqGrid(‘setGridParam’,{datatype:’json’}); },50);
});
 If any one faces any problem with the above mentioned implementation please post a reply to this topic.
Regards,
Aarati
i do have some problem populating a json object values to my gridÂ
can you help me???
Hi aarati,
Can u provide me full code which is mentioned above.I need it very urgently Pls reply fast.
Thanks,
anees.iny
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top