Kendo Grid problems to show data returned with JSon

4 posts, 0 answers
  1. JspringfielCR
    JspringfielCR avatar
    3 posts
    Member since:
    May 2016

    Posted 10 May Link to this post

    Hello, I recently update the Kendo version of my project to 2016.1.226.545, and after that I can't show the data on the grids i have, the first time a page load the grid is empty, if I click any column, like sorting the grid, display a Json Object on the screen. Am I losing a js file to add or has anyone an idea what could be happening? Before the update the code was working perfectly.

    Here is how i am doing the code, 

     

    View

                        @(Html.Kendo().Grid<Project.Models.Products>()
                        .Name("Products")
                        .Scrollable()
                        .Sortable()
                        .EnableCustomBinding(true)
                        .HtmlAttributes(new { style = "height:auto;" })
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .Model(model =>
                            {
                                model.Id(x => x.Code);
                            })
                            .ServerOperation(false)
                            .PageSize(20)
                            .Read(read => read.Action("LoadProducts", "Products"))
                            )

                        .Columns(columns =>
                        {
                            columns.Bound(p => p.Product).Title("Product").Width(70);
                            columns.Bound(p => p.Code).Title("Code").Width(70);
                            columns.Bound(p => p.Description).Title("Description").Format("{0:0,0.0}").Width(250);

                        }))

     

    Controller

     

            public ActionResult Products()
            {
                return View();
            }

     
            public ActionResult LoadProducts([DataSourceRequest]DataSourceRequest request)
            {
                clsData cns = new clsData();

                IQueryable<consultProducts> s2 = cns.getProducts().ToList().AsQueryable();

                DataSourceResult result = s2.ToDataSourceResult(request, p => new Products
                {
                    Code= p.code,
                    Product= p.product,
                    Description= p.description,

                });

                return Json(result, JsonRequestBehavior.AllowGet);
            }

     

    And the result is a Json object like this 

     

    {"Data":[{"Code":0001,"Description":"Natural oil","Product":01}],"Total":1,"AggregateResults":null,"Errors":null}

  2. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 12 May Link to this post

    Hi,

    Thank you for contacting us.

    I tried to replicate the issue locally but I was unable to. Could you please check out the attached sample and let me know how it differs from your real setup? I would appreciate if you can replicate the issue in my sample in order to investigate it locally. The view name is Products/Index.

    I am looking forward to your reply.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. JspringfielCR
    JspringfielCR avatar
    3 posts
    Member since:
    May 2016

    Posted 12 May in reply to Kostadin Link to this post

    Hi Kostadin!

    Thanks for the answer, I was examining your sample, first thing the Kendo reference was missing, so I added this one 2016.1.226.440, and the problem still appear. 

    I attached some pics that will show you the result.

     

    By the way on my solution, I got the data be display on the grid, by changing the ActionResult to JsonResult on the controller, like this


            public Json LoadProducts([DataSourceRequest]DataSourceRequest request)
            {
                clsData cns = new clsData();
                IQueryable<consultProducts> s2 = cns.getProducts().ToList().AsQueryable();

                DataSourceResult result = s2.ToDataSourceResult(request, p => new Products
                {
                    Code= p.code,
                    Product= p.product,
                    Description= p.description,

                });

                return Json(result, JsonRequestBehavior.AllowGet);
            }

    Also I'm rendering this js files

                bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
                          "~/Scripts/kendo.aspnetmvc.min.js",
                          "~/Scripts/kendo.all.min.js",
                          "~/Scripts/kendo.core.min.js",
                          "~/Scripts/kendo.web.min.js",
                          "~/Scripts/kendo.grid.min.js",
                          "~/Scripts/kendo.aspnetmvc.js",
                          "~/Scripts/kendo.all.js",
                          "~/Scripts/kendo.core.js",
                          "~/Scripts/kendo.web.js",
                          "~/Scripts/jszip.js",
                          "~/Scripts/kendo.grid.js"

                    ));

    But the result is not the efficient enough that I expect, I will continue doing test and let you know.

    Have a nice day.! 

  5. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 16 May Link to this post

    Hi,

    I removed the Kendo reference and all the packages in order to reduce the size of the archive. Nevertheless, on my side the project works correctly with the same version of Kendo. Could you please try replicating the issue in a small runnable sample and send it to me in order to investigate it locally?

    I am looking forward to your reply.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready