Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
430
Iggrid with relation in bbdd doesn't works
posted

Hi all, 

I have a iggrid that works perfectly, in the moment at I add a relation to the table database the same grid doesn't works. It's normal?

I can't do this work?

i put mi grid code:

<div style="width: 100%; float: left; height: 510px; padding-bottom: 20px;">
@( Html.Infragistics().Grid<DOCUMENTOS>()
.ID("igGrid1")
.PrimaryKey("uniCODOBJ")
.Columns(column =>
{
column.For(x => x.uniCODOBJ).DataType("string").HeaderText("ID").Width("150px");
column.For(x => x.strTITOL).DataType("string").HeaderText("Títol");
column.For(x => x.strNOMPRO).DataType("string").HeaderText("Nom Productor");
column.For(x => x.datFECCRE).DataType("date").HeaderText("Data").Format("dd/MM/yyyy");
})
.Features(features =>
{
features.Paging().PageSize(10).PrevPageLabelText("Anterior").NextPageLabelText("Següent");
features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings =>
{
settings.ColumnSetting().ColumnKey("strNOMPRO").AllowSorting(true);

});
features.Selection().MouseDragSelect(true).MultipleSelection(true).Mode(SelectionMode.Row);
features.Filtering().ColumnSettings(settings =>
{
settings.ColumnSetting().ColumnKey("datFECCRE").AllowFiltering(true).FilterCondition("equals");
});

})

.ClientDataSourceType(ClientDataSourceType.JSON)
.DataSourceUrl(Url.Action("GetDocumentosList"))
.Width("100%")
.Height("100%")
.LocalSchemaTransform(true)
.DataBind()
.Render()
)
</div>

Parents
No Data
Reply
  • 49378
    posted

    Hello Ruben,

    Thank you for posting in our community !

    Are you binding the grid directly to an Entity Framework Model in this case ? If the grid is bound directly to an entity which has a relation with a child entity, a "Circular Reference" exception is likely to occur as the JSON Serializer attempts to serialize an object which has a relation to a child object, which in its place has a reference to the parent object.

    If that is the case, there are a couple of approaches that can be used to avoid such issues. One would be to set all navigation properties in the Entities which point to their related entities by setting their access modifiers to internal instead of public.

    The other approach would be to create a Data Transfer Object.  A Data Transfer Object, or DTO, is at its most basic a Plain Old CLR Object (POCO) that contains just the properties that you need from the entity.  In your DTO you would create any properties that you need from your entity and exclude any of the navigation or other properties that you don't need.  This will help with the serializer and can also help improve the performance of requests to your server for more data.  For more information about DTOs, please see the following pages:

    http://msdn.microsoft.com/en-us/library/ff649585.aspx

    Hope this helps. Please do not hesitate to contact me with any questions.

     

     

     

Children
No Data