Data Source Issues

0 Answers 227 Views
Data Source
Kerry
Top achievements
Rank 1
Kerry asked on 12 Sep 2021, 08:20 PM | edited on 12 Sep 2021, 08:24 PM

Hello I am coming from Kendo for Core. I am trying to get data from the database but im not sure where im going wrong.

Here is my controller action and the call from the webpage.

   public IActionResult GetRoles()
        {
            var Roles = _context.AspNetRoles.ToList();

            return Json(Roles);
        }

  $("#grid").kendoGrid({
                dataSource: {
                    type: "json",
                    transport: {
                        read: '../Admin/GetRoles'
                    },
                    pageSize: 20
                },

This works locally but when i publish to the server it cannot find the method.  I looked at the service they have posted but im not sure what i would need to do.

 

local does give an error but the data shows

kendo.all.js:2178 Unknown DataSource transport type 'json'.
Verify that registration scripts for this type are included after Kendo UI on the page.
Ianko
Telerik team
commented on 15 Sep 2021, 10:13 AM

There is no built-in transport type "json". Here is the list of the available ones: https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/type

This configuration defaults to the default transport type which should be fine for the case. As for why the action is not found I can only assume that when the application is published it navigates to the incorrect route. I suggest you trying to use Url.Action helper: 

 

 $("#grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: '@Url.Action("GetRoles", "Admin")'
                    },
                    pageSize: 20
                },

If this does not help, double-check whether you can access the action without the grid and see if it is a valid route.

No answers yet. Maybe you can help?

Tags
Data Source
Asked by
Kerry
Top achievements
Rank 1
Share this question
or