My child grid data model is like:
var gridDetailModel = function( $gridMain, rowData ){
return {
height: 130,
//pageModel: { type: "local", rPP: 5, strRpp: "" },
dataModel: {
url: "/ExpenseManagement/departmentHead",
location: 'remote',
//sorting: 'local',
dataType: 'JSON',
data: JSON.stringify(jsonToBeSend),
async: true,
beforeSend: function(xhr,setting) {
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
},
method: "POST",
//contentType:'application/json; charset=UTF-8',
error: function () {
//$gridMain.pqGrid( 'rowInvalidate', { rowData: rowData });
}
//url = "/pro/orderdetails.php?orderId=" + orderID //for PHP
},
colModel: [
{ title: "BranchName", width: 80, dataIndx: "branchId" }
],
editable: false,/*
groupModel: {
dataIndx: ["branchId"],
dir: ["up"],
title: ["{0} - {1} product(s)"],
icon: [["ui-icon-triangle-1-se", "ui-icon-triangle-1-e"]]
}, */
flexHeight: true,
flexWidth: true,
numberCell: { show: false },
title: "Order Details",
showTop: false,
showBottom: false
};
JSON data:
/* var jsonToBeSend=new Object();
jsonToBeSend["id"] = 1;
jsonToBeSend["success"] = true;
jsonToBeSend["message"] = "ghgj"; */
/* var jsonToBeSend="{\"data\":{\"id\":1}}"; */
var jsonToBeSend={"id":1};
I tried all the combination of JSON.
I getting below error:
11:38:46.051 DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [public java.util.List<com.chaitanya.departmentHead.model.DepartmentHeadDTO> com.chaitanya.web.controller.DepartmentHeadController.getDepartmentHead(com.chaitanya.ajax.AjaxResponse)]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized token 'pq_datatype': was expecting ('true', 'false' or 'null')
at [Source: java.io.PushbackInputStream@5af5c788; line: 1, column: 13]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'pq_datatype': was expecting ('true', 'false' or 'null')
at [Source: java.io.PushbackInputStream@5af5c788; line: 1, column: 13]
Controller:
@RequestMapping(value="/departmentHead",method=RequestMethod.POST,headers = "Accept=application/json", produces = "application/json")
public @ResponseBody List<DepartmentHeadDTO> getDepartmentHead(@RequestBody AjaxResponse receivedDepartmentHeadDTO){
List<DepartmentHeadDTO> departmentHeadDTOList = null;
LoginUserDetails user = (LoginUserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if(Validation.validateForNullObject(user.getLoginDTO().getEmployeeDTO())){
// departmentHeadDTOList = deptHeadSerrvice.findDepartmentHeadUnderCompany(receivedDepartmentHeadDTO);
}
return departmentHeadDTOList;
}
POJO class:
public class AjaxResponse {
Long id;
boolean success;
String message;
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Please help. Is there something i am missing in POST call.
Because I able make ajax call in my project from your inline grid.