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

one to many relationship

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ahmad
Top achievements
Rank 1
Ahmad asked on 03 Sep 2013, 11:20 PM
I have two model.
When I want to display a list of Product in grid, if PurchaseInvoiceDetail have records, Product grid show empty list,
and when i delete PurchaseInvoiceDetail records, Product's grid display list of product.
(I use Editing_Popup grid)
public class Product
    {
        [Key]
        [ScaffoldColumn(false)]
        public int ProductId { get; set; }       
        public string Name { get; set; }
        public int Number { get; set; }
 
        public virtual ICollection<PurchaseInvoiceDetail> PurchaseInvoiceDetail { get; set; }
    }
 
public class PurchaseInvoiceDetail
    {
        [Key]
        public int PurchaseInvoiceDetailId { get; set; }
        public int Number { get; set; }
        public decimal PurchasePrice { get; set; }
 
        //Navigation Properties
 
        public int ProductId { get; set; }
        public virtual Product Product { get; set; }
    }

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 05 Sep 2013, 10:31 AM
Hi Ahmad,


The most probable reason for the issue is that a circular reference was detected when serializing th objects. It is caused because both of the classes have properties that reference to each other, which the JavaScript serialize cannot handle. As a resolution for this issue you should extract a ViewModel of the data, which excludes those properties. You could take a look at the following documentation page for additional details.

 

Regards,
Dimiter Madjarov
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
Ahmad
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or