@page "/"
@using Syncfusion.Blazor.Grids
<SfGrid TValue=@Contact
DataSource=@SelectedJob.Customer.Contacts>
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Normal"></GridEditSettings>
<GridColumns>
<GridColumn Field="@nameof(Contact.ContactID)" IsPrimaryKey="true"></GridColumn>
<GridColumn Field="@nameof(Contact.Name)"></GridColumn>
<GridColumn Field="@nameof(Contact.CustomerID)"></GridColumn>
</GridColumns>
</SfGrid>
@code{
public Job SelectedJob { get; set; }
protected override void OnInitialized() {
var job = new Job() {
JobID = 1,
};
var customer = new Customer {
CustomerID = 1,
};
job.Customer = customer;
customer.Job = job;
customer.Contacts = Enumerable.Range(1, 75).Select(x => new Contact() {
ContactID = x,
Name = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
CustomerID = 1,
Customer = customer,
}).ToList();
SelectedJob = job;
}
public class Customer {
public long CustomerID { get; set; }
public long JobID { get; set; }
public Job Job { get; set; }
public ICollection<Contact> Contacts { get; set; }
}
public class Contact {
public long ContactID { get; set; }
public string Name { get; set; }
public long CustomerID { get; set; }
public Customer Customer { get; set; }
}
public class Job {
public long JobID { get; set; }
public long CustomerID { get; set; }
public Customer Customer { get; set; }
}
}