Problem in return data from controller using api read

0 Answers 59 Views
Charts Data Source Grid
kha
Top achievements
Rank 1
Iron
Iron
kha asked on 22 Oct 2023, 05:37 AM

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>"   }
                            
                        ]
                    });

kha
Top achievements
Rank 1
Iron
Iron
commented on 24 Oct 2023, 02:39 PM

Plz reply i need help..Experts
Georgi Denchev
Telerik team
commented on 25 Oct 2023, 12:29 PM

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

kha
Top achievements
Rank 1
Iron
Iron
commented on 25 Oct 2023, 01:33 PM

Yes . i check the Network , there is no response.Once it return in json formate then it is easy to handle. I think i am going somwthing wrong with calling the Java mvc controller (
 return "${pageContext.request.contextPath}/charts";
)
kha
Top achievements
Rank 1
Iron
Iron
commented on 25 Oct 2023, 01:59 PM

@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. 

Georgi Denchev
Telerik team
commented on 30 Oct 2023, 08:31 AM

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

No answers yet. Maybe you can help?

Tags
Charts Data Source Grid
Asked by
kha
Top achievements
Rank 1
Iron
Iron
Share this question
or