Hello,
I am trying to do a Basic MVC application with Grid Control. I followed the Tutorial Videos at www.youtube.com/watch . The Code looks exactly similar discussed in the video except for the Entity Framework which I used my Models.
The Problem I faced was Grid control was not able to fetch the data from a Entity Framework Model that had relationships from the Controller. and when looking at the console found out the error as
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Uncaught Error: The remote request to fetch data has failed: (error) undefined - in ig.ui.min.js
I debugged the Controller and I can see the data that are being returned. Also I Checked out the Forums for similar posts and found out this and my problem looks similar to what they have discussed.
https://es.infragistics.com/community/forums/f/ignite-ui-for-javascript/58125/grid-not-displaying-data
With Entity Models that has relationships, I get the above error. So I tested with a model that did not have any relationships associated with them and I was able to get grid working.
I am not sure what the problem is or am I missing anything ?
Thanks!
Hi,
The error you are describing is a client-side error but the root of the issue exists on the server. My first recommendation is to debug the server code in Visual Studio and see what the exception is there.
If I had to guess, you are probably getting a circular reference exception. This occurs because the JSON serializer is trying to serialize collections and the relationship between the collections creates a circular instance. For instance in Northwind: Customers have Orders which have Employees which have Customers which have Orders, etc. There's no way the JSON serializer can determine where to stop serializing the data.
You can check out this discussion at the StackOverflow link below but the bottom line is that in your application you should create a simple ViewModel that you can use to serialize your data. Populate the ViewModel from your Entity Framework code and then set this ViewModel collection to your grid - it will more cleanly separate your data access code from your view and may also save you some bandwidth by only serializing the properties that you really do need for the view. Hope that helps, here's the StackOverflow link:
http://stackoverflow.com/questions/5678015/entity-framework-4-1-mvc3-jsonresult-and-circular-references
Hello,Please let me know if you have any further questions regarding this issue. Did you manage to resolve the issue via Aaron's suggestions?