0
I have 3 classes being Contact, Sector, Unit so I have Contact with one to many relationship with Sector and Unit generating Json with many layers, making it impossible for Jquery Bootgrid to access these fields.
Checking Jquery Bootgrid documentation I noticed that it does not support data-column-id="Unit.Name"
Class Contact
public class Contato
{
[Key]
public int ContatoID { get; set; }
public string Nome { get; set; }
public int UnidadeID { get; set; }
public Unidade Unidade { get; set; }
public int SetorID { get; set; }
public Setor Setor { get; set; }
}
Class Unit
public class Unidade
{
[Key]
public int UnidadeID { get; set; }
public string Nome { get; set; }
}
Sector Class
public class Setor
{
[Key]
public int SetorID { get; set; }
public string Nome { get; set; }
}
These classes are generating the following JSON
rows: [
{
ContatoID: 4,
Nome: "Luiz",
UnidadeID: 1,
Unidade: {
UnidadeID: 1,
Nome: "Oeste Paulista Setor 1"
},
}
The controller’s Return responsible for returning Json is this
return Json(new {
rows = contatosPaginados.ToList(),
current = current,
rowCount = rowCount,
total = total
}, JsonRequestBehavior.AllowGet);
The question is how do I get Json to come all at the same level?
[{
ContatoID: 4,
Nome: "Luiz",
Ramal: "9500",
UnidadeID: 1,
NomeUnidade: "Oeste Paulista Setor 1"
}]