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

Ajax Grid now showing data in ASP.NET MVC

10 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darius
Top achievements
Rank 1
Darius asked on 09 Sep 2013, 12:40 PM
Hello there,

I am trying the simple example on the site (Ajax Grid Biding and Editing) and the Grid isn't showing me any data. I tried the server binding and it works. Below is my code.

Razor:
@(Html.Kendo().Grid<KendoTest2.Models.DocumentType>()
      .Name("grid")
      .DataSource(dataSource => dataSource // Configure the grid data source
          .Ajax() // Specify that ajax binding is used
          .Read(read => read.Action("Products_Read", "Home")) // Set the action method which will return the data in JSON format
       )
      .Columns(columns =>
      {
          // Create a column bound to the ProductID property
          columns.Bound(product => product.Id);
          // Create a column bound to the ProductName property
          columns.Bound(product => product.Name);
          // Create a column bound to the UnitsInStock property
        
      })
      .Pageable() // Enable paging
      .Sortable() // Enable sorting
)
Controller:

public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request)
        {
            using (var northwind = new MMCC_DocumentManagementEntities())
            {
                IQueryable<DocumentType> products = northwind.DocumentTypes;
                DataSourceResult result = products.ToDataSourceResult(request);
                return Json(result);
            }
        }
It's the simple example on the site, adapted on my model. That's all. Not showing data. I checked and the Json(result) returns data. What could it be the problem?

10 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 10 Sep 2013, 07:48 AM
Hi Darius,

I reviewed the attached code, but could not find the reason for this behavior just by looking at it. Could you please provide runnable project where the issue is reproduced? This makes it is much easier to focus on the particular issue which usually leads to its faster resolving.
 

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Darius
Top achievements
Rank 1
answered on 10 Sep 2013, 09:01 AM
Hello Alexander,

Thanks for your answer. I don't know if giving you the solution will help because you will still not have the database (from which the model is generated) so you will still not have any result to see.

If you want, and you think it will help, I can give you any kind of source-code or source-code files.

Thanks
0
Alexander Popov
Telerik team
answered on 10 Sep 2013, 09:33 AM
Any test project that reproduces the issue should suffice, even if it uses the Northwind database.

Thanks,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Darius
Top achievements
Rank 1
answered on 10 Sep 2013, 09:59 AM
Ok, here is the weird thing. I started building a test project for you and I imported the Products table in a test database. Guess what, it works. If I use the model generated from my database it doesn't. Same steps, same code. What could it be the problem?
0
Darius
Top achievements
Rank 1
answered on 10 Sep 2013, 11:55 AM
I found the problem: http://feedback.kendoui.com/forums/127393-kendo-ui-feedback/suggestions/3024077-make-grid-or-data-source-parse-related-object-pr

Now I need to find the solution, any suggestions?
0
Alexander Popov
Telerik team
answered on 11 Sep 2013, 03:34 PM
Hello Darius,

I am afraid that parsing the nested items type is currently is not supported, however looking at the attached code snippets this shouldn't be related. Please provide runnable project where the issue is observed so we can advice you further.
 

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Darius
Top achievements
Rank 1
answered on 11 Sep 2013, 03:53 PM
It is related because I found that if I leave Lazy Loading to value true then the grid will show no values, even if I don't try to get a related element.
0
Vladimir Iliev
Telerik team
answered on 13 Sep 2013, 08:35 AM
Hi Darius,

 
Please note that as my colleague Alexander mention in his previous posts - in current case we can't help much without a runable project that reproduces the issue on our side. I would suggest to check this blog post which provides more information about how to isolate an issue in example project. 

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Milos
Top achievements
Rank 1
answered on 10 Feb 2014, 12:19 PM
Hello,
I am having exactly the same problem, and i also found out that when i turn Lazy Loading OFF, my data are showing up.
Here is a code part

In my Controller
Function Zaposleni_Read(request As DataSourceRequest) As ActionResult
            Using db As New Kontrolori_smeneEntities
                Dim result As List(Of Zaposleni) = db.Zaposlenis.ToList              
                Return Json(result.ToDataSourceResult(request))
            End Using
        End Function
In my View
Html.Kendo().Grid(Of TelerikMvcApp3.Zaposleni)() _
            .Name("Grid") _
            .Columns(Sub(c)
                             c.Bound(Function(p) p.Ime)
                             c.Bound(Function(p) p.Prezime)                            
                     End Sub) _
        .Pageable() _
        .Sortable() _
        .Filterable() _
        .DataSource(Function(d)
                            d.Ajax().Read(Function(read) read.Action("Zaposleni_Read", "Zaposleni"))
                    End Function) _
        .Render()


Any help why is this related to Lazy Loading?
0
Vladimir Iliev
Telerik team
answered on 12 Feb 2014, 02:11 PM
Hi Milos,

From the provided information it's not clear for us what is the exact reason for current behavior. That why I would ask you to open a new support thread and provide the error message that you are receiving on the server / client side. Also if possible please provide runable project where the issue is reproduced - this would help us pinpoint the exact reason for this behavior.

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Darius
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Darius
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Milos
Top achievements
Rank 1
Share this question
or