Good day.

I have several objects, a table of techniques, with a Child-Parent connection inside the table (refers to itself)

public class Technic { //Π­Ρ‚ΠΎ Идишник public Guid Id {get;set;} public string Name {get;set;} public int? Count { get; set; } public DateTime? ArrivalTime { get; set; } //Ρ‚ΡƒΡ‚ ΡƒΠΊΠ°Π·Π°Π½Π° ссылка Π½Π° запись Π²Π½ΡƒΡ‚Ρ€ΠΈ Ρ‚Π°Π±Π»ΠΈΡ†Ρ‹ Ρ‚Π΅Ρ…Π½ΠΈΠΊΠΈ public Guid? ParentId {get;set;} //Если запись Parent установлСно Π½Π° true public bool IsParent {get;set;} } 

and let the main model be Parking

 public class Parking { public Guid Id {get;set;} public string Name {get;set;} [UIHint("Technic")] public List<Technic> ParkingTechnic{get;set;} } 

so i have a controller

 public ActionResult ParkingAdd(){ var model = new Parking(){Id=Guid.NewGuid(), Name="ВСст"}; //Π΄ΠΎΠ±Π°Π²ΠΈΠΌ ΠΊΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΠΈ model.ParkingTechnic.Add(new Technic(){Id = Guid.NewGuid(), Name = "ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ1", IsParent = true}); model.ParkingTechnic.Add(new Technic(){Id = Guid.NewGuid(), Name = "ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ2", IsParent = true}); //Π΄ΠΎΠ±Π°Π²ΠΈΠΌ Ρ‚Π΅Ρ…Π½ΠΈΠΊΡƒ model.ParkingTechnic.Add(new Technic(){Id = Guid.NewGuid(), Name = "Π’Π΅Ρ…Π½ΠΈΠΊΠ°1", IsParent = false, ParentId=model.ParkingTechnic.First(l=>l.Name == ""ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ1"").Id}); model.ParkingTechnic.Add(new Technic(){Id = Guid.NewGuid(), Name = "Π’Π΅Ρ…Π½ΠΈΠΊΠ°2", IsParent = false, ParentId=model.ParkingTechnic.First(l=>l.Name == ""ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ1"").Id}); model.ParkingTechnic.Add(new Technic(){Id = Guid.NewGuid(), Name = "Π’Π΅Ρ…Π½ΠΈΠΊΠ°3", IsParent = false, ParentId=model.ParkingTechnic.First(l=>l.Name == ""ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ1"").Id}); //Π”ΠΎΠ±Π°Π²ΠΈΠΌ Ρ‚Π΅Ρ…Π½ΠΈΠΊΡƒ ΠΊ Π²Ρ‚ΠΎΡ€ΠΎΠΉ ΠΊΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΠΈ model.ParkingTechnic.Add(new Technic(){Id = Guid.NewGuid(), Name = "Π’Π΅Ρ…Π½ΠΈΠΊΠ°4", IsParent = false, ParentId=model.ParkingTechnic.First(l=>l.Name == ""ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ2"").Id}); model.ParkingTechnic.Add(new Technic(){Id = Guid.NewGuid(), Name = "Π’Π΅Ρ…Π½ΠΈΠΊΠ°5", IsParent = false, ParentId=model.ParkingTechnic.First(l=>l.Name == ""ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡ2"").Id}); return View(model) } 

Here is a view

 @Html.HiddenFor(m=>m.Id) @Html.TextBoxFor(m=>m.Name) //ΠžΡ‚ΠΏΡ€Π°Π²ΠΈΠΌ список Π² шаблон @Html.EditorFor(m=>m.ParkingTechnic) 

But the pattern

 @model List<Technic> @{ for (int i = 0; i> model.count(); i++){ @Html.LabelFor(m => m[i].Name) @Html.TextBoxFor(m => m[i].Count) @html.TextBoxFor(m => m[i].ArrivalTime) } } 

In this scenario, he spits out all the entries from the collection of technology. The question is how to make it display categories as labels and grouped vehicles under them.

  • Category1
    • Technique1 - date and quantity input field
    • Technique2 - date and quantity input field
    • Technique3 - date and quantity input field
  • Category 2
    • Technique4 - this technique has the second category, input field and dates
    • Technique5 - input field and date
  • Do you want to only display List<Technic> or do you need the ability to send changes to the server? - Dmitry
  • At the moment I want to make a form, I will generate details on the object using a different template. So yes, I need an Editor to send data to the server. Now I have decided it, the truth is rather rude and dreary. Sorting in sequence, and then drawing in order, with verification. But not elegant. . . - Erkin Mukhamedkulov

0