This is a migrated thread and some comments may be shown as answers.

How to load web api json data into kendo grid

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sandy
Top achievements
Rank 1
Iron
Veteran
sandy asked on 10 Nov 2020, 12:22 PM

how to load external epi data into kendo grid. am getting empty grid using below code. but in api it shows it is returning json data.

here is my code.

@(Html.Kendo().Grid<TimeControlReportEnhancements.Models.TimeControlGrid>()
          .Name("grid")
          .Columns(columns =>
          {
              columns.Bound(p => p.EMPNAME);
              columns.Bound(p => p.COMPANY).Width(150);
              columns.Bound(p => p.PROJECTNAME).Width(150);
              columns.Bound(p => p.CHARGEDESC).Width(150);
              columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
          })
          .ToolBar(tools =>
          {
              tools.Create();
          })
          .Sortable()
          .Pageable()
          .Filterable()
          .DataSource(dataSource =>
              dataSource
                .WebApi()
                .Model(model =>
                {
                    model.Id(p => p.EMPNUMBER);
                })
          .Events(events => events.Error("error_handler"))
          .Read(read => read.Url("https://localhost:44376/api/Home/DBA"))
         
          )

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 12 Nov 2020, 08:17 AM

Hi Sandy,

The provided configuration seems correct and I could not suggest a possible reason for the observed behavior. Could you please check if there are errors in the browser console? You could take a look at the Web API binding demo linked here. Another example of Grid with HTML helpers bound to Web API is linked here. You could find more example with Grid and Web API binding in the following repo:

- https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid

You could also take a look at the Forum thread linked below where a similar issue is discussed:

- https://www.telerik.com/forums/trouble-populating-grid-from-web-api-json#IiXmMuznCUC1oY8fLvRhAw

If the issue continues to persist, could you please try to prepare an isolated sample where the issue is replicated and send it back to us? This way we could troubleshoot locally and advise you further.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
sandy
Top achievements
Rank 1
Iron
Veteran
Answers by
Neli
Telerik team
Share this question
or