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
645
Code first and IgGrid
posted

hi,
I am using a model with Code First, and I have a relationship between two tables 1: N.

I have classes: Person and computer.


model:

Public Class Computer
Property Id As Integer
Property Idperson As System.Nullable(Of Integer)

Overridable Property person As Person
End Class


Public Class Person
Property Id As Integer
Property Name As String
Property LastName As Stringh

Overridable Property Computers As List(Of Computer)
End Class


Public Class DbMyModel
Inherits DbContext

Property Persons As DbSet(Of Person)
Property Computers As DbSet(Of Computer)

Protected Overrides Sub OnModelCreating(modelBuilder As DbModelBuilder)
MyBase.OnModelCreating(modelBuilder)
modelBuilder.Configurations.Add(New ComputerConfiguracion)
End Sub

End Class

Public Class ComputerConfiguracion
Inherits EntityTypeConfiguration(Of Computer)

Sub New()
HasOptional(Function(o) o.person).WithMany(Function(n) n.computers).HasForeignKey(Function(o) o.Idperson)
End Sub
End Class


controller:



Namespace Mvc4Ejemplo
Public Class TestController
Inherits System.Web.Mvc.Controller

Private db as new DbMyModel


<GridDataSourceAction> _
<ActionName("PagingGetData")> _
Public Function Index() As ActionResult
Return View(db.Computers.ToList.AsQueryable)
End Function



End Class
End Namespace



View:

@Imports Infragistics.Web.Mvc
@ModelType IQueryable(of Mvc4Ejemplo.Computer)
@Code
ViewData("Title") = "Index"
End Code
@Section Scripts
<link href="~/Scripts/jQuery/Common/CSS/structure/modules/infragistics.ui.grid.css" rel="stylesheet" />

<script src="~/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="~/Scripts/jQuery/jquery-1.7.1.js" type="text/javascript"></script>
<script src="~/Scripts/jquery-ui-1.8.20.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery-ui-1.8.20.js" type="text/javascript"></script>
<script src="~/Scripts/jQuery/Common/js/infragistics.loader.js" type="text/javascript"></script>
<script src="~/Scripts/jQuery/Common/js/infragistics.js" type="text/javascript"></script>

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")

End Section

<div id="content">

@(Html.Infragistics().Grid(Model).ID("grid1").PrimaryKey("ID") _
.AutoGenerateColumns(True) _
.Features(Sub(features2)
features2.Paging()
features2.Selection.Mode(SelectionMode.Row).MultipleSelection(False)
features2.Updating() _
.EnableAddRow(True).AddRowLabel("Añadir nueva fila") _
.EnableDeleteRow(False) _
.EditMode(GridEditMode.Row) _
.ColumnSettings(Sub(setting)
setting.ColumnSetting().ColumnKey("ID").ReadOnly(True)
End Sub)
End Sub).Width("705").Height("500") _
.DataSourceUrl(Url.Action("PagingGetData")).DataBind().Render())

</div>

Give a problem with DynamicProxies model.
With this type of model, is the infragistics grid I can display the model?
I need that when you find navigation properties, show me Overrides toString Object.
And then I would like to edit a row, you can access the navigation property that references to in order to change it.
By this I mean, when I want to edit the row, leave all fields as usual, but the property of the class Person Computer, is, for example, a button, and pressing it and do what I need.


Thanks in advance.

Best regards.