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

[Solved] Circular reference, broken link

4 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lee
Top achievements
Rank 1
Lee asked on 20 Jun 2011, 09:39 AM
I have come across the circular reference issue whilst trying to use Ajax databinding with the grid.  There is a blog discussing this issue, but the following link is broken  circular reference was detected blog  Can this be made available again please?

Many Thanks,
Lee.

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 20 Jun 2011, 11:45 AM
Hello Lee,

The blog post is available at the following URL:

http://blogs.telerik.com/aspnetmvcteam/posts/10-01-25/resolving_circular_references_when_binding_the_mvc_grid.aspx

Greetings,
Dimo
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Radu
Top achievements
Rank 1
answered on 21 Jun 2011, 07:53 PM
Hi,

First, thanks for the link. It does clarify a few issues, but I'm in the following configuration:

MVC 3
Telerik 2011.1.315
and Entity Framework 4.1 in Code-First mode. 

Of the provided solutions; using Server-side binding is not an option; I have a pretty big project, so ViewModel definitely would be a last resort.

Can you please give an example of how the second solution ("Avoid generating reference properties") can be implemented for EF Code-First mode?

Many thanks!
0
Rosen
Telerik team
answered on 22 Jun 2011, 09:40 AM
Hello Radu,

You may disable serialization of the navigation properties by disabling the ProxyCreation options of the DataContext. 

[GridAction]
public ActionResult _Select()
{
    var db = new Northwind();
    db.Configuration.ProxyCreationEnabled = false;
    return Json(new GridModel(db.Products));
}

where data context has following declaration:

public class Product
{
    public int ProductID { get; set; }
    public string ProductName { get; set; }
    public decimal? UnitPrice { get; set; }
    public int CategoryID { get; set; }
    
    public virtual Category Category { get; set; }
}
 
public class Category
{
    public int CategoryID { get; set; }
    public string CategoryName { get; set; }
    public string Description { get; set; }
}
 
public class Northwind : DbContext
{
    public DbSet<Category> Categories { get; set; }
    public DbSet<Product> Products { get; set; }
}

Regards,
Rosen
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Lee
Top achievements
Rank 1
answered on 24 Jun 2011, 10:26 AM
Hi Dimo,

Thanks very much for the link.  After giving the users a quick demo they didn't want an editable grid after all so this resolved the issue as I no longer needed to have Ajax support.

Many Thanks again,
Lee.
Tags
Grid
Asked by
Lee
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Radu
Top achievements
Rank 1
Rosen
Telerik team
Lee
Top achievements
Rank 1
Share this question
or