This is a migrated thread and some comments may be shown as answers.
Kendo Grid problems to show data returned with JSon
4 Answers 120 Views
This is a migrated thread and some comments may be shown as answers.
JspringfielCR
Top achievements
Rank 1
JspringfielCR asked on 10 May 2016, 01:32 PM

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}

4 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 12 May 2016, 10:37 AM
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
0
JspringfielCR
Top achievements
Rank 1
answered on 12 May 2016, 02:54 PM

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

0
Kostadin
Telerik team
answered on 16 May 2016, 05:52 AM
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
0
Alexander
Top achievements
Rank 1
answered on 09 May 2020, 02:00 AM
most probably your kendo.all.min.js reference wrong path.
Tags
Grid
Asked by
JspringfielCR
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
JspringfielCR
Top achievements
Rank 1
Alexander
Top achievements
Rank 1
Share this question
or