i have controller using java as @RequestMapping("/charts") and it return in Json format but my question this data is not reflected in my Grid why.
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: function(options)
{ return "${pageContext.request.contextPath}/charts";
},
dataType: "json",
type: "GET"
}
},
schema:{
model: {
fields: {
id: { type: "number" },
fullName : { type: "string" },
address: { type: "string" },
email : { type: "string" },
password: { type: "string" },
designation: { type: "string" },
salary: { type: "number" }
}
}
},
aggregate: [ { field: "fullName", aggregate: "count" },
{ field: "salary", aggregate: "sum" }
]
,pageSize: 8 },
sortable: true,
scrollable: false,
pageSize: 5,
pageSizes: true,
hieght:20,
pageable: {
pageSizes: [4, 6,10,"all"],
buttonCount: 5
},
columns: [
{ field: "id", title: "ID", width: 180 },
{ field: "fullName", title: "Name",width:300,
template: "<div style=color:red>#=fullName#</div>" ,footerTemplate: "Total Count: #=count#" },
{ field: "address", title: "Address",width:300 },
{ field: "email", title: "Email",width:200},
{ field: "password", title: "Password" ,width:200},
{ field: "designation", title: "Designation" ,width:300},
{ field: "salary", title: "Salary" ,width:200,footerTemplate: "Total Sum: #=sum#"},
{ width:200,
template: "<a class='k-button' href='/Home/Index'>Redirect</a>" }
]
});
Hello, Kha,
Could you please check the Network tab using the browser Devtools(F12) and examine the response from the server? It should have a format similar to the following one:
// JSON response { data: [{id: 1, fullName: "test", /*the rest of the fields*/}, {id: 2, fullName: "test 2", /*the rest of the fields*/}, /* more data */] }
Best Regards,
Georgi
@Georgi
Thanks for your reply as you mentioned i check the network, but nothing is happened in response, please review my code i think i am going something wrong either calling the controller or something else which i don't understand please help.
Hello, Kha,
The configuration that you shared looks correct. The problem is likely server related so you'd have to debug it yourself. Make sure that the request reaches the correct controller action and then ensure that the action returns data in the format that I previously shared.
Best Regards,
Georgi